2014-01-13 70 views
2

我遇到了著名的WCF錯誤:爲什麼我仍然得到「傳入消息的最大消息大小限額(65536)已超出」錯誤?

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.

閱讀前五名谷歌搜索結果這個錯誤後,我仍然沒有什麼可能是錯誤的我服務的配置任何線索/客戶。

我曾嘗試:

  1. Setting maxReceivedMessageSize

  2. Setting maxBufferSize and maxBufferPoolSize

  3. Adding readerQuotas

  4. Ensuring the values are the same for the client and the server.

  5. Ensuring binding configuration is specified by name.

  6. Including the namespace in the service name.

注意的是:

  • 小消息被正確地傳送,而是從客戶發送大量消息到當上述發生錯誤服務器。

  • 太大的消息包含一個大約350 KB的字節數組(假定WCF配置爲將base64編碼爲二進制數據)。 (1)雙向通信,其中(2)使用網絡TCP綁定與(3)可靠會話和(4)排序設置(這四點與我已經看到的每個例子都不同錯誤)。

  • 該服務由IIS託管快遞安裝與Visual Studio 2012

這是我的配置。任何提示?

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
          multipleSiteBindingsEnabled="true" /> 
<bindings> 
    <netTcpBinding> 
    <binding name="netTcpEndpoint" 
      receiveTimeout="00:10:00" 
      sendTimeout="00:10:00" 
      maxBufferSize="2147483647" 
      maxReceivedMessageSize="2147483647" 
      maxBufferPoolSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" 
        maxArrayLength="2147483647" 
        maxStringContentLength="2147483647" 
        maxBytesPerRead="2147483647" 
        maxNameTableCharCount="2147483647"/> 
     <reliableSession ordered="true" 
         inactivityTimeout="00:10:00" 
         enabled="false" /> 
     <security mode="None"> 
     <message clientCredentialType="None" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="DebugOrientedBehavior" 
      name="DemoNamespace.PipeService"> 
    <endpoint address="Default.svc" 
       binding="netHttpBinding" 
       name="TransportLayerServiceEndpoint" 
       contract="DemoNamespace.IPipeService" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://example.com/Default.svc" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="DebugOrientedBehavior"> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

客戶端配置是這樣的一個:

<bindings> 
    <netHttpBinding> 
    <binding name="TransportLayerServiceEndpoint" 
      receiveTimeout="00:10:00" 
      sendTimeout="00:10:00" 
      maxBufferPoolSize="2147483647" 
      maxBufferSize="2147483647" 
      maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" 
        maxArrayLength="2147483647" 
        maxStringContentLength="2147483647" 
        maxBytesPerRead="2147483647" 
        maxNameTableCharCount="2147483647"/> 
     <reliableSession ordered="true" 
         enabled="false" /> 
     <webSocketSettings transportUsage="Always" /> 
    </binding> 
    </netHttpBinding> 
</bindings> 
<client> 
    <endpoint address="ws://example.com/Default.svc/Default.svc" 
      binding="netHttpBinding" 
      bindingConfiguration="TransportLayerServiceEndpoint" 
      contract="PipeServiceReference.IPipeService" 
      name="TransportLayerServiceEndpoint" /> 
</client> 

回答

2

您的服務配置似乎有一個問題 - 你沒有bindingConfiguration服務端點指定netHttpBinding,並且您已經爲netTcpBinding定義的配置(但顯然不使用)。此配置的相關服務部分位於此處:

<endpoint address="Default.svc" 
      binding="netHttpBinding" 
      name="TransportLayerServiceEndpoint" 
      contract="DemoNamespace.IPipeService" /> 

請注意,沒有設置bindingConfiguration值。我會建議增加在客戶端定義的服務配置綁定配置,然後更新服務端點,以使用綁定:

<endpoint address="Default.svc" 
      binding="netHttpBinding" 
      bindingConfiguration="TransportLayerServiceEndpoint" 
      name="TransportLayerServiceEndpoint" 
      contract="DemoNamespace.IPipeService" /> 

目前您的服務使用的缺省值netHttpBinding,這可能是原因你仍然得到錯誤。

+0

非常好。事實上,我錯過了名稱不匹配以及不同類型綁定之間的混亂。萬分感謝。 –

+1

@MainMa - 不客氣。即使在.NET 4.0中引入了默認的端點/綁定MS,配置文件和WCF也會帶來許多麻煩。 – Tim

相關問題