【发布时间】:2013-01-16 04:21:24
【问题描述】:
我对 WCF Web 服务的调用失败并显示 System.Net.WebException: The request failed with HTTP status 413: Request Entity Too Large.
检查 Fiddler,我看到我正在发送:
内容长度:149839
超过 65KB。
在服务器上启用 WCF 跟踪,我看到了:
System.ServiceModel.ProtocolException:最大消息大小配额 已超出传入消息 (65536)。为了增加 配额,在适当的地方使用 MaxReceivedMessageSize 属性 绑定元素。
添加此属性并不能解决问题。
我只尝试了该属性,并且(后来)尝试了帖子建议的其他各种属性。这是我目前拥有的(在服务器上):
<basicHttpBinding>
<binding name="PricerServiceSoap"
closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
我的唯一端点(<client> 下)是:
<endpoint address="/NetPricingService/Service.asmx"
binding="basicHttpBinding" bindingConfiguration="PricerServiceSoap"
contract="Pricing.PricerService.PricerServiceSoap"
name="PricerServiceSoap" />
我还添加了:
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
在<behavior>下。
我什至运行过(对于 IIS 7):
%windir%\system32\inetsrv\appcmd set config "WebServicesDev/PricingService"
-section:requestFiltering -requestLimits.maxAllowedContentLength:104857600
-commitpath:apphost
没什么区别。
一个问题是这是一个 WCF 服务,旨在替换旧的 ASMX 服务。服务框架是使用现有 WSDL 中的 svcutil 生成的。我无法更改客户端配置(并且客户端使用多种语言)。我的测试客户端项目使用添加 Web 引用(在Add Service Reference / Advanced 下)导入了服务,所以我没有 WCF 配置。但是,如果我将其指向较旧的 ASMX 服务,则测试客户端可以正常工作。
如何解决或诊断此问题?
其他信息
如果我使用 Microsoft 服务配置编辑器生成配置(设置 maxReceivedMessageSize 和 maxBufferSize),它可以工作。问题是端点随后在<service> 下指定,它不会让我指定/NetPricingService/Service.asmx 相对地址。如果我在 svcutil 生成的配置中编辑绑定(端点位于 <client> 下),它不适用于大型请求。
【问题讨论】:
标签: wcf iis .net-4.0 web-config wcf-binding