2012-01-22 20 views
0

我有一個問題,我試圖從我的WCF服務傳輸大量的對象。我必須將對象的傳輸限制爲100,否則會出現某種通信錯誤。仍然無法通過WCF傳輸大量數據 - 還有什麼問題?

我嘗試瞭解決方案中的建議,發現here,但也許我錯過了一些東西,因爲我仍然收到錯誤。

這裏是我的WCF服務的web.config文件的底部:

<system.web> 
    <httpRuntime maxRequestLength="102400" /> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="MyWsHttpBinding" /> 
     </wsHttpBinding> 
     <netTcpBinding> 
     <binding name="myNetTcpBinding" 
       closeTimeout="00:01:00" 
       openTimeout="00:01:00" 
       receiveTimeout="00:10:00" 
       sendTimeout="00:01:00" 
       transactionFlow="false" 
       transferMode="Buffered" 
       transactionProtocol="OleTransactions" 
       hostNameComparisonMode="StrongWildcard" 
       listenBacklog="10" 
       maxBufferPoolSize="2147483647" 
       maxBufferSize="524288" 
       maxConnections="10" 
       maxReceivedMessageSize="2147483647"> 
      <readerQuotas maxDepth="32" 
         maxStringContentLength="8192" 
         maxArrayLength="16384" 
         maxBytesPerRead="4096" 
         maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" 
          inactivityTimeout="00:10:00" 
          enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="myNetTcpBehaviour"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior>   
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="myNetTcpEndPointBehaviour"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

接下來,這裏是消耗Web服務的網站的Web.config部分下部:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IFeederService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="55000" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <behaviors> 
     <endpointBehaviors> 
     <behavior name="myEndPointBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 

    <client> 

     <endpoint address="http://www.mysiate.com/MyService.svc" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFeederService" 
     contract="FeederService.IFeederService" name="BasicHttpBinding_IFeederService" /> 
    </client> </system.serviceModel> 

我得到的錯誤是:在接收到 HTTP響應發生

錯誤。這可能是由於服務 端點綁定不使用HTTP協議。這也可能是由於 對HTTP請求上下文被服務器中止(可能由於服務關閉導致 )。查看服務器日誌獲取更多詳細信

奇怪的是,當我寫這篇文章時,我重新嘗試將返回邏輯改爲190個對象,並且工作正常。重試,並失敗。

這可能是改變一些IIS設置的問題?

任何這方面的援助將不勝感激。

謝謝。

+0

如何[此](http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/ 686499d2-5e31-47ee-941B-760264472875 /)? –

+0

這也可能有助於http://stackoverflow.com/questions/1281269/response-size-limitaiton-of-a-wcf-web-serivces。問題可能是由於basichttpbinding配置的大小限制。 – Muthu

+0

您轉賬總共有多少? –

回答

1

您還沒有宣佈在服務配置的任何端點,這意味着在WCF默認端點模型被用來

但是,你命名你的綁定配置和行爲,這意味着它們不會被拾起默認端點。如果您從綁定配置和行爲中刪除名稱,則它們將成爲默認設置,並將被默認端點拾取。

1

錯誤消息說:

...查看服務器日誌的更多細節。

我首先在服務器上配置跟蹤,如this MSDN article中所述。

0

您的綁定需要將行爲配置設置爲您的行爲。

<endpoint address="http://www.mysiate.com/MyService.svc" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFeederService" 
    behaviorConfiguration="myEndPointBehavior" contract="FeederService.IFeederService" name="BasicHttpBinding_IFeederService" /> 
</client> </system.serviceModel> 

否則圖表的設置不會被使用