WCF服务错误“超出了传入消息的最大消息大小配额”

问题描述 投票:0回答:1

我有一个WCF服务库项目,该项目从数据库请求大记录集并返回它。每次在WCF测试客户端中都会弹出此错误。我将MaxReceivedMessageSize更改为一个较大的值,但似乎没有接受。这里是Web.Config

 <client>
  <endpoint address="http://localhost:8000/SAPIntranet" binding="basicHttpBinding"
    bindingConfiguration="Binding_SAPIntranet" contract="SAPIntranet"
    name="SAPIntranet" kind="" endpointConfiguration="" />
</client>
<bindings>
  <basicHttpBinding>
    <binding name="Binding_SAPIntranet" openTimeout="00:02:00" maxBufferPoolSize="20000000"
      maxBufferSize="20000000" maxReceivedMessageSize="20000000">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </basicHttpBinding>
</bindings>

错误消息始终提供默认值(65535)。我想我做错了什么,但无法弄清楚。

感谢您的时间和帮助

vb.net web-services wcf wcf-binding
1个回答
0
投票

MaxReceivedMessageSize设置在服务器端生效,我们应该在服务端点上应用绑定配置。上面的配置仅适用于客户端服务端点。请参考以下服务配置。

  <services>
    <service name="WcfService1.Service1">
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="mybinding" contract="WcfService1.IService1">
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    </service>
  </services>
  <bindings>
    <basicHttpBinding>
      <binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>

随时告诉我是否有什么我可以帮助的。

© www.soinside.com 2019 - 2024. All rights reserved.