maxReceivedMessageSize 未修复 413:请求实体太大 [英] maxReceivedMessageSize not fixing 413: Request Entity Too Large

查看:38
本文介绍了maxReceivedMessageSize 未修复 413:请求实体太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WCF Web 服务的调用失败,出现 System.Net.WebException: The request failed with HTTP status 413: Request Entity Too Large.

My call to my WCF web service is failing with System.Net.WebException: The request failed with HTTP status 413: Request Entity Too Large.

检查 Fiddler,我看到我正在发送:

Checking Fiddler, I see that I'm sending:

内容长度:149839

Content-Length: 149839

超过 65KB.

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

Enabling WCF tracing on the server, I see:

System.ServiceModel.ProtocolException: 最大消息大小配额已超过传入消息 (65536).为了增加配额,在适当的情况下使用 MaxReceivedMessageSize 属性绑定元素.

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.

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

Adding this property doesn't solve the issue.

我已经尝试过仅使用该属性,并且(后来)尝试使用帖子建议的其他各种属性.这是我目前拥有的(在服务器上):

I've tried with just that property, and (later) with various others that posts have suggested. Here's what I have currently (on the server):

<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>

我唯一的端点(在 下)是:

My sole endpoint (under <client>) is:

<endpoint address="/NetPricingService/Service.asmx"
  binding="basicHttpBinding" bindingConfiguration="PricerServiceSoap"
  contract="Pricing.PricerService.PricerServiceSoap"
  name="PricerServiceSoap" />

我还添加了:

<dataContractSerializer maxItemsInObjectGraph="2147483647"/>

下.

我什至运行过(对于 IIS 7):

I've even run (for IIS 7):

%windir%system32inetsrvappcmd set config "WebServicesDev/PricingService"
-section:requestFiltering -requestLimits.maxAllowedContentLength:104857600
-commitpath:apphost

没有任何区别.

一个问题是,这是一个 WCF 服务,旨在替换旧的 ASMX 服务.服务框架是使用 svcutil 从现有 WSDL 生成的.我无法更改客户端配置(并且客户端使用多种语言).我的测试客户端项目使用 Add Web Reference 导入了服务(在 Add Service Reference/Advanced 下),所以我没有 WCF 配置.但是,如果我将其指向较旧的 ASMX 服务,则测试客户端可以工作.

One catch is that this is a WCF service meant to replace an older ASMX service. The service skeleton was generated with svcutil from existing WSDL. I can't change the client configurations (and the clients are in multiple languages). My test client project imported the service with Add Web Reference (under Add Service Reference / Advanced), so I have no WCF configuration. However, the test client works if I point it at the older ASMX service.

我该如何解决或诊断此问题?

How can I fix or diagnose this?

其他信息

如果我使用 Microsoft 服务配置编辑器来生成配置(设置 maxReceivedMessageSize 和 maxBufferSize),它就可以工作.问题是端点是在 下指定的,它不会让我指定/NetPricingService/Service.asmx 相对地址.如果我在 svcutil 生成的配置中编辑绑定(端点位于 下),它不适用于大型请求.

If I use the Microsoft Service Configuration Editor to generate the config (setting maxReceivedMessageSize and maxBufferSize), it works. The problem is that the endpoint is then specified under <service>, and it won't let me specify the /NetPricingService/Service.asmx relative address. If I edit the bindings in the svcutil-generated config (where the endpoint is under <client>), it doesn't work with large requests.

推荐答案

答案正盯着我的脸.

svcutil 生成的配置是针对客户端的.我在服务器上使用它.

The config generated by svcutil was for the client. I was using it on the server.

我正在编辑 下指定的端点的绑定,这对服务完全没有影响.

I was editing the bindings for the endpoints specified under <client>, which made absolutely no difference to the service.

添加适当的 端点并在其绑定上设置 maxReceivedMessageSize 和 maxBufferSize 解决了该问题.

Adding a proper <service> endpoint and setting the maxReceivedMessageSize and maxBufferSize on its binding resolved the issue.

这篇关于maxReceivedMessageSize 未修复 413:请求实体太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆