【发布时间】:2014-09-09 14:23:13
【问题描述】:
我在调用我的 WCF 服务更大的请求 XML 对象内容长度 65708 时遇到异常,它在请求 XML 文件内容长度小于此长度时没有任何问题。
这是我们向外部客户端公开的服务,我使用 SoapUI 调试该服务,我收到异常 HTTP/1.1 400 Bad Request[\r][\n] 甚至没有到达调试点。我在网上搜索并应用了提供的配置值,但它们都没有帮助我解决问题。
所有配置更改后,我的 web.config 文件如下所示(仅绑定部分)。
<bindings>
<basicHttpBinding>
<binding name="GDASHttp" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
我没有更改客户端文件中的任何设置,因为我可以从 SoapUI 获取异常并且问题仅与服务器配置有关。我确实了解某些设置根据文件大小接受的问题,但不确定我们可以在上述设置中提供的最大值是多少。
我根据 Google 在服务器中的一些建议修改了 IIS 设置,这是我更改后的 applicationhost.config 文件。
<location path="Default Web Site/GDAS.FY15R2.3.1/Trusted" overrideMode="Allow">
<system.webServer>
<handlers accessPolicy="Read, Execute" />
<security>
<ipSecurity>
<add ipAddress="127.0.0.1" subnetMask="255.255.255.255" allowed="true" />
</ipSecurity>
<requestFiltering>
<requestLimits maxAllowedContentLength="40000000" />
</requestFiltering>
</security>
<serverRuntime uploadReadAheadSize="2147483647" />
</system.webServer>
</location>
【问题讨论】:
-
值得注意的是,400 中的 HTTP 状态代码(即 400 错误请求)指向源自客户端而非服务器端的问题。服务器问题通常会产生 500 秒的状态代码。
标签: c#