WCF的大请求返回404,maxReceivedMessageSize =“2147483647”
我们WCF大请求返回下面的错误服务:WCF的大请求返回404,maxReceivedMessageSize =“2147483647”
“System.ServiceModel.EndpointNotFoundException:没有终点的http://xxx.svc是可以接受的消息听。 ---> System.Net.WebException:远程服务器返回一个错误:(404)Not Found。
对于小的请求一切正常,我得到正确的WCF服务响应,这个问题只是与大的请求。
在客户机上设置如下:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITestService" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:33333/TestService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" contract="TestService.ITestService" name="BasicHttpBinding_ITestService" />
</client>
</system.serviceModel>
WCF服务的设置:
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
什么可以是问题?
在这种情况下,错误不是在WCF中,而是在IIS设置下。 该消息对于IIS来说很大,我在服务器上的web.config中添加了“maxAllowedContentLength”。
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2200000000"/>
</requestFiltering>
</security>
错误消息是误导性的。
@DamienPawski你是怎么弄出来的? – 0x4f3759df 2016-11-29 14:46:42
我希望我能给10个upvotes。谢谢! – denvercoder9 2017-05-02 20:55:19
在我的情况下,即使尝试所有解决方案并将所有限制设置为最大值后,它仍然无法正常工作。在最后,我发现IIS /网站上安装了一个微软IIS过滤模块Url Scan 3.1,它有自己的限制,根据内容大小拒绝传入的请求并返回“404未找到页面”。
通过将MaxAllowedContentLength
设置为所需的值,可以更新%windir%\System32\inetsrv\urlscan\UrlScan.ini
文件中的限制。
例如,以下将允许高达300 MB的请求
MaxAllowedContentLength = 314572800
可能重复:http://stackoverflow.com/questions/17572500/wcf-error-there-was-no-endpoint-listening-at – Mike 2015-02-24 18:09:01
我有上述问题提供的设置。 – DamianPawski 2015-02-25 11:43:05