【问题标题】:WCF maxReceivedMessageSize not working over HTTPSWCF maxReceivedMessageSize 无法通过 HTTPS 工作
【发布时间】:2015-04-09 15:23:42
【问题描述】:

我正在尝试使用 WCF 服务通过 HTTPS 使用 SSL 来接收大型 XML 消息。我的应用程序基于 .NET Framework 4.5 构建并部署在 IIS 8.5 服务器上。

使用以下 Web.Config 配置,我能够通过 HTTP 接收大型 XML,但它会在 HTTPS 上出现一些问题。 (HTTPS 通信已经正常工作,带有自签名证书等)。

   <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
      </basicHttpBinding>

      <basicHttpsBinding>
         <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
      </basicHttpsBinding>
    </bindings>

    <behaviors>   
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>

使用 SoapUI 执行一些测试,大文件仅在定义更新时通过 HTTPS 发送(即使 Web.Config 文件中没有任何更改)。

当外部系统(来自 SAP 的 TIBO/PI)调用我们的服务时,simplr 不起作用,并显示以下错误消息:

HTTP/1.1 413 请求实体太大 缓存控制:私有 服务器:Microsoft-IIS/8.0 X-AspNet-版本:4.0.30319 X-SourceFiles: =?UTF-8?B?QzpcVkFMRVxDb2RpZ28tYnJhbmNoLW9uZGExLW9uZGEyLW1lcmdlXFN1cHBsaWVyRmluYW‌​5jZS5XZWJTZXJ2aWNlc1xDb250cmF0b3Muc3Zj?= X-Powered-By:ASP.NET 日期:2015 年 4 月 9 日星期四 22:28:41 GMT 内容长度:0

【问题讨论】:

  • 你能显示客户端代理和端点的配置吗?
  • 到目前为止,我正在使用 SoapUI 进行测试(没有成功,但也没有特殊配置)并且在 Web.config 上没有明确的端点(因此,所有端点都使用相同的配置)。

标签: .net wcf ssl https maxreceivedmessagesize


【解决方案1】:

试试这个绑定(我明确指定了绑定的名称,所以在服务配置中使用它)

<basicHttpBinding>
    <binding maxReceivedMessageSize="10485760">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="10485760" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None"/>
    </binding>
</basicHttpBinding>
<basicHttpsBinding>
    <binding maxReceivedMessageSize="10485760">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="10485760" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None"/>
    </binding>
</basicHttpsBinding>

如果还是不行试试添加

<system.webServer>
    <serverRuntime uploadReadAheadSize="2147483646"/>
</system.webServer>

给你配置。希望对您有所帮助。

【讨论】:

    【解决方案2】:

    那是因为你只有 basicHttpBinding 的配置,而没有 basicHttpsBinding 的配置。为基于 SSL 的绑定创建默认配置:

       <bindings>
          <basicHttpBinding>
            <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
          </basicHttpBinding>
          <basicHttpsBinding>
            <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
          </basicHttpsBinding>
        </bindings>
    

    【讨论】:

    • 我已经在我的 Web.config 上应用了这个附加标签。但是,该解决方案似乎不稳定,一会儿就起作用,然后又停止工作。你能想象是什么原因造成的吗?
    • 当它“不起作用”时,它的表现如何?错误?如果有,是哪一个?
    • HTTP / 1.1 413请求实体过大的Cache-Control:私人服务器:IIS / 8.0 X-ASPNET-版本:4.0.30319 X-SourceFiles:???= UTF-8乙QzpcVkFMRVxDb2RpZ28tYnJhbmNoLW9uZGExLW9uZGEyLW1lcmdlXFN1cHBsaWVyRmluYW5jZS5XZWJTZXJ2aWNlc1xDb250cmF0b3Muc3Zj ?= X-Powered-By: ASP.NET Date: Thu, 09 Apr 2015 22:28:41 GMT Content-Length: 0
    • 您肯定会超出配置的限制。你试过增加它吗?
    • 配置的限制是业务需求,但是,我们正在使用受控的较小大小对其进行测试。所有测试在 HTTP 上都可以正常工作,但有些测试在 HTTPS 上是间歇性的(正如我所说,有时它们可​​以工作,有时它们不工作)。问题出现在我们的本地机器和 DEV 机器上。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 2018-02-12
    • 2017-12-01
    • 2011-05-22
    • 1970-01-01
    相关资源
    最近更新 更多