2011-04-09 42 views
6

我有一個應用程序使用WCF和netTcpBinding上傳大文件。對於特定文件,我收到錯誤消息:傳入消息的最大消息大小配額已被超出(明顯的修復不起作用)

傳入消息(65536)的最大消息大小配額已超出。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。

這是我在客戶web.config文件綁定(客戶端是一個ASP.NET網站):

<binding name="DataImportEndpoint" closeTimeout="00:20:00" openTimeout="00:01:00" 
     receiveTimeout="00:20:00" sendTimeout="00:20:00" transferMode="Buffered" 
     hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
     maxBufferSize="5242880" maxReceivedMessageSize="5242880"> 
     <readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="Transport"> 
     <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
     </security> 
    </binding> 

我意識到我還需要更改服務配置的maxReceivedMessageSize財產。所以我加了這個結合:

<bindings> 
    <netTcpBinding> 
    <binding name="NetTcpLarge" 
      maxReceivedMessageSize="5242880" maxBufferSize="5242880"> 
     <readerQuotas maxStringContentLength="524288"/> 
    </binding> 
    </netTcpBinding> 
</bindings> 

和修改我的終點:

<endpoint address="DataImportService" binding="netTcpBinding" 
     name="DataImportEndpoint" bindingConfiguration="NetTcpLarge" 
     contract="IDataImportService" /> 

這個固定的問題,當我運行的自我在Visual Studio主辦。但是,在IIS 7上運行的實例中,我是仍然獲得與65536已超出相同的錯誤。我在這裏錯過了什麼嗎?我甚至已將此添加在IIS 7例如我的服務配置,但無濟於事:

<system.webServer> 
    <security> 
     <requestFiltering> 
      <requestLimits maxAllowedContentLength="5242880" /> 
     </requestFiltering> 
    </security> 
</system.webServer> 

回答

6

如果異常仍是相同的IIS,它無關<requestLimits>,除了清楚地表明,maxReceivedMessageSize超過。我將捕獲詳細級別的WCF跟蹤並檢查在端點上應用了哪些綁定配置。

我建議你重新檢查客戶端和服務配置,如果仍然沒有線索,請在詳細級別捕獲服務和客戶端的跟蹤。

+2

確實,綁定配置沒有被應用。 web.config中的服務名稱與.svc文件(其中一個具有完整的名稱空間)中的服務名稱不匹配,因此正在應用默認端點!感謝您的建議 – pjacko 2011-04-18 14:53:57

0

聽起來像你可能會超過IIS的「maxRequestLength」緩衝區大小。默認的大小是......你猜,65536.嘗試添加以下行到你的web.config文件:

<system.web> 
    <compilation debug="true"/> 
    <httpRuntime maxRequestLength="5242880"/> 
</system.web> 
+3

默認大小爲4096 KB(4 MB)。 http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx – StarCub 2011-11-27 22:20:07

相關問題