1

我正在尝试使用 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 Request Entity Too Large Cache-Control: private Server: Microsoft-IIS/8.0 X-AspNet-Version: 4.0.30319 X-SourceFiles: =?UTF-8?B?QzpcVkFMRVxDb2RpZ28tYnJhbmNoLW9uZGExLW9uZGEyLW1lcmdlXFN1cHBsaWVyRmluYW‌​5jZS5XZWJTZXJ2aWNlc1xDb250cmF0b3Muc3Zj?= X-Powered-作者:ASP.NET 日期:2015 年 4 月 9 日星期四 22:28:41 GMT 内容长度:0

4

2 回答 2

1

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

   <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
      </basicHttpBinding>
      <basicHttpsBinding>
        <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
      </basicHttpsBinding>
    </bindings>
于 2015-04-09T20:35:36.643 回答
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>

给你配置。希望能帮助到你。

于 2015-04-29T10:15:53.300 回答