2014-03-27 120 views
1

我有兩個分離的模塊(基於Web的GUI和基於WCF的服務器),我使用WCF服務引用訪問從我的GUI到服務器的一些方法。當GUI從服務器請求數據並向GUI發送大量數據時會發生此問題;引發最大郵件大小錯誤異常! 我在Web.config文件中增加了適當的部分標記中的消息大小,它暫時工作,但是當數據總是增長到我的情況時,達到允許的最大大小時,錯誤再次發生!我知道瓶頸在GUI一邊! 我該如何解決這個問題,並且有什麼方法可以使GUI服務引用來處理不斷增長的數據? 這裏是我的GUI web.config文件:WCF服務消息大小錯誤

<pre> 
</system.webServer> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IServerHelper" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="16777216" maxBufferPoolSize="524288" maxReceivedMessageSize="16777216" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" > 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 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://172.16.16.7:123456/ServerServices" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServerHelper" contract="ServiceReference1.IServerHelper" name="BasicHttpBinding_IServerHelper"/> 
    </client> 
</system.serviceModel> 
</pre> 

謝謝你幫我...

回答

0

您可以設置這些值高達int.MaxValue。如果這還不足以滿足您的回覆消息,您應該嘗試拆分消息。畢竟,這將是2GB的消息。也許SOAP不是運送這種野獸的最佳方式。

+0

我該如何分割我的信息?你有什麼建議? (給出的代碼示例非常棒!) – user2240957

+0

@ user2240957這非常依賴於您的用例。特別是考慮到通過SOAP發送2GB並不是一個好的開始。如果您需要獲得2GB數據,請考慮更適合該任務的方式。你的客戶有6GB RAM嗎?因爲如果您在GUI中執行MVVM並且您從服務中獲得2GB,那麼這將是您所需要的。 – nvoigt

+0

你說的是正確的nvoigt!我應該使用更合適的解決方案 – user2240957