【问题标题】:WCF MaxReceivedMessageSize: maximum message size quota exceededWCF MaxReceivedMessageSize:超出最大邮件大小配额
【发布时间】:2010-12-07 02:43:18
【问题描述】:

我收到此错误:

传入邮件的最大邮件大小配额 (65536) 已达到 超过。要增加配额,请使用 MaxReceivedMessageSize 相应绑定元素上的属性。

如何在 WCF 客户端应用程序或服务器应用程序中增加此值,如果可能,请举例说明如何做到这一点?

【问题讨论】:

    标签: wcf


    【解决方案1】:

    你在客户端的 app/web.config 中增加它:

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="WSBigQuotaConfig" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                        <message clientCredentialType="UserName" algorithmSuite="Default"/>
                    </security>
                </binding>
          </basicHttpBinding>
      </bindings>
    
      <client>
          <endpoint 
              address="http://example.com/endpoint.svc"
              binding="basicHttpBinding"
              bindingConfiguration="WSBigQuotaConfig"
              contract="ISomeServiceContract" />
      </client>
    </system.serviceModel>
    

    【讨论】:

    • +1 和 Accepted,但还值得一提的是,当传输模式 = buffered - maxBufferSize 和 maxReceivedMessageSize 应该包含相同的值......
    • maxBufferSize 和 maxReceivedMessageSize 不匹配会导致异常。
    【解决方案2】:

    您需要在绑定配置中设置 MaxReceivedMessageSize 属性。默认情况下,它是 65536。我假设您使用的数据集或类似性质的东西最终会非常大(主要是因为它们通常用 XML 表示)。

    好消息是我认为您只需要在客户端配置中进行更改即可。看看下面。

    <bindings>
       <netTcpBinding>
          <binding name="MyTcpBinding"
                   maxReceivedMessageSize="2000000"/>
       </netTcpBinding>
    <bindings>
    

    【讨论】:

      【解决方案3】:

      <bindings>
        <wsHttpBinding>
          <binding name="wsHttpBinding_Username" maxReceivedMessageSize="20000000"          maxBufferPoolSize="20000000">
            <security mode="TransportWithMessageCredential">
              <message clientCredentialType="UserName" establishSecurityContext="false"/>
            </security>
          </binding>
        </wsHttpBinding>
      </bindings>
      
      <client>
        <endpoint
                  binding="wsHttpBinding"
                  bindingConfiguration="wsHttpBinding_Username"
                  contract="Exchange.Exweb.ExchangeServices.ExchangeServicesGenericProxy.ExchangeServicesType"
                  name="ServicesFacadeEndpoint" />
      </client>
      

      【讨论】:

        猜你喜欢
        • 2010-11-11
        • 2018-01-15
        • 2015-09-15
        • 2015-06-13
        • 2012-03-13
        • 2014-02-13
        • 2014-10-06
        • 2013-04-22
        • 2012-05-14
        相关资源
        最近更新 更多