簡體   English   中英

仍無法通過WCF傳輸大量數據 - 還有什么問題?

[英]Still unable to transfer large amounts of data via WCF - what else is wrong?

我有一個問題,我正在嘗試從我的WCF服務傳輸大量對象。 我必須將對象的傳輸限制為100,否則會出現某種通信錯誤。

我嘗試了解決方案中的建議,在這里找到,但也許我錯過了一些東西,因為我仍然得到錯誤。

這是我的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://www.mysite.com/MyService.svc的HTTP響應時發生錯誤。 這可能是由於服務端點綁定不使用HTTP協議。 這也可能是由於服務器中止HTTP請求上下文(可能是由於服務關閉)。 請參閱服務器日志以獲取更多詳

關於這一點的奇怪之處在於,當我寫這篇文章時,我通​​過將返回邏輯更改為190個對象來重試它,並且它有效。 重試了,但失敗了。

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

對此有任何幫助將不勝感激。

謝謝。

您尚未在服務配置中聲明任何端點,這意味着正在使用WCF默認端點模型

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

錯誤消息說:

...有關詳細信息,請參閱服務器日志

我將首先在服務器上配置跟蹤,如本MSDN文章中所述

你不能使用'流媒體'WCF綁定嗎?

WCF和流媒體

您的綁定需要根據您的行為設置行為配置。

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

否則,不會使用圖形設置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM