gpt4 book ai didi

wcf - maxReceivedMessageSize 未修复 413 : Request Entity Too Large

转载 作者:行者123 更新时间:2023-12-03 10:22:19 25 4
gpt4 key购买 nike

我对 WCF Web 服务的调用失败并显示 System.Net.WebException: The request failed with HTTP status 413: Request Entity Too Large.
检查 fiddler ,我看到我正在发送:

Content-Length: 149839



超过 65KB。

在服务器上启用 WCF 跟踪,我看到:

System.ServiceModel.ProtocolException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.



添加此属性并不能解决问题。

我只尝试了该属性,并且(后来)尝试了帖子建议的其他各种属性。这是我目前拥有的 (在服务器上) :
<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 生成的配置中编辑绑定(bind)(端点位于 <client> 下),它不适用于大请求。

最佳答案

我也遇到了这个问题,并在 fiddler 中意识到正在工作的最大 Content-Length 最终为 30000000。

在验证我的 WCF 配置是否正确后,我发现一篇文章建议修改 IIS 设置请求筛选。

Large file upload failure for Web application calling WCF service – 413 Request entity too large

  • 打开 IIS 管理器
  • 选择您的应用程序
  • 选择请求过滤图标。
  • 选择编辑功能设置...(右侧面板)
  • 调整最大允许内容长度(字节)默认显示为 30000000

  • 或 web.config 文件示例
    <system.webServer>
    <security>
    <requestFiltering>
    <requestLimits maxAllowedContentLength="50000000" />
    </requestFiltering>
    </security>
    </system.webServer>

    关于wcf - maxReceivedMessageSize 未修复 413 : Request Entity Too Large,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14636407/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com