2009-10-15 110 views
10

我收到此錯誤:WCF MaxReceivedMessageSize:最大郵件大小超出配額

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.

我如何能在WCF客戶端應用程序或服務器應用程序增加該值,如果可能的如何做到這一點的例子?

回答

18

您在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> 
+4

1和接受,而且值得一提的是,當傳輸模式=緩衝 - MAXBUFFERSIZE和maxReceivedMessageSize應包含相同的值.... – 2009-10-15 16:57:49

+1

maxBufferSize和maxReceivedMessageSize之間的不匹配會導致異常。 – Kangkan 2011-08-24 09:23:15

3

您需要設置MaxReceivedMessageSize屬性,在綁定的配置。默認情況下,它是65536.我假設你使用的是數據集,或者是那種性質非常大的東西(主要是因爲它們通常用XML表示)。

好消息是我認爲你只需要在你的客戶端配置中改變它。看看下面。

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

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

相關問題