2011-09-08 78 views
2

調用wcf服務(wshttpbinding)時出現錯誤。我已經將MaxReceivedMessageSize設置爲最大值(2147483647)。任何人都可以告訴我什麼是錯的?WCF MaxReceivedMessageSize錯誤

我正在使用「安全模式=」消息「」,這是一個問題嗎?

錯誤: 傳入消息的最大消息大小配額(65536)已被超出。爲了增加配額,使用MaxReceivedMessageSize屬性相應的綁定元素

配置上:(客戶端)

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="wsDemo" closeTimeout="00:15:00" openTimeout="00:15:00" 
      receiveTimeout="00:15:00" sendTimeout="00:15:00" bypassProxyOnLocal="false" 
      transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <reliableSession ordered="true" inactivityTimeout="00:15:00" 
      enabled="false" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://demo.com/DemoServices/DemoProduct.svc" 
     binding="wsHttpBinding" bindingConfiguration="wsDemo" contract="DemoService.IProducts" 
     name="wsDemo"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

服務器配置:

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="LargeWS" name="GexaEnrollCustomer.GexaEnroll"> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="SecureBinding" 
      name="wsDemo" contract="MyInterfaces.IProducts"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" name="wsMex" 
      contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://demo.com/DemoServices/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="LargeWS"> 
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="200" maxConcurrentSessions="200" /> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="SecureBinding" maxBufferPoolSize="2147483647" closeTimeout="00:15:00" openTimeout="00:15:00" 
      receiveTimeout="00:15:00" sendTimeout="00:15:00" maxReceivedMessageSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> 

    </system.serviceModel> 

回答

5

注意,錯誤消息指出「爲傳入消息「,這導致我相信它是服務器端拋出此錯誤,而不是客戶端。除了客戶端之外,您可能還需要在服務器上設置MaxReceivedMessageSize

通常,您可以將客戶端和服務器的配置設置爲相同的大小。

+0

是的。我做到了。這裏是服務器配置。看看我的第一條消息。 – CoolArchTek

0

您還需要更改maxBufferSize。

相關問題