c# maxreceivedmessagesize 不工作

c# maxreceivedmessagesize not working

我在项目中引用了这个外源服务,调用它时出现以下错误:

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

所以我在网络配置中修复了我的绑定,如下所示:

<client>
  <endpoint address="MY SERVICE ADDRESS"
    binding="basicHttpBinding" bindingConfiguration="MyBinding"
    contract="MyContract" name="MyImplPort" />
</client>

并在绑定中:

<bindings>
  <basicHttpBinding>
    <binding name="MyBinding" maxBufferPoolSize="2000000000"
      maxBufferSize="2000000000" maxReceivedMessageSize="2000000000"/>
  </basicHttpBinding>
</bindings>

但是我仍然得到同样的错误。
有办法解决这个问题吗?

你增加了你的readerQuotas吗??

readerQuotas 定义了可以由配置了绑定的端点处理的 SOAP 消息复杂性的约束。

像这样:

<binding name="MyBinding" maxBufferPoolSize="2000000000"
      maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32" 
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
</binding>

您没有提及在发送请求或接收响应时是否遇到此错误。如果是在接收响应时,限制对应于您已经设置的客户端。如果您在发送请求时遇到此错误,则此限制在服务器端,您需要增加服务器端的限制。

这是一个example