WCF MaxReceivedMessageSize:超出最大邮件大小配额

JL.*_*JL. 11 wcf

我收到此错误:

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

如何在WCF客户端应用程序或服务器应用程序中增加此值,并在可能的情况下举例说明如何执行此操作?

Dar*_*rov 19

您在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>
Run Code Online (Sandbox Code Playgroud)

  • +1和接受,但也值得一提的是,当传输模式=缓冲时 - maxBufferSize和maxReceivedMessageSize应该包含相同的值.... (4认同)