我在WCF中創建了一個Web服務,該服務返回每行有10個數據的54000多個數據行。我已經使用wsHttpBinding進行通信。該服務在數據較少(即2000行)的情況下工作良好,但當嘗試發送50000行(〜2MB)的大型記錄集時,該服務會彈出。異常消息是這樣的在WCF服務中傳輸大量數據
接收到對
http://localhost:9002/MyService.svc
的HTTP響應時發生錯誤。這可能是由於服務端點綁定不使用HTTP協議。這也可能是由於HTTP請求上下文被服務器中止(可能是由於服務關閉)。查看服務器日誌獲取更多詳細信
請不要告訴我在客戶端使用分頁 - 我知道它會解決問題。但是我需要客戶端的整個數據塊。在服務器
我的服務配置是
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyWsHttpBinding" />
</wsHttpBinding>
</bindings>
<services>
<service name="AdminService">
<endpoint address="AdminSrv"
binding="wsHttpBinding"
contract="IAdminService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="/Bus/IRfotoWCF" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<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>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"></serviceHostingEnvironment>
</system.serviceModel>
我的客戶端配置是
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAdminService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
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://localhost/TestService/AdminService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAdminService"
contract="IAdminService" name="BasicHttpBinding_IAdminService" />
</client>
</system.serviceModel>
會有人幫助我無論是在客戶端和服務器端的配置excact。即使我需要更改綁定從wsHttpBinding到netTcpBinding - 我沒有這樣做的問題。提前致謝。
我不明白。這是一個非常好的解決方案,當一個服務在5.20分鐘內等待另一個服務時。我認爲這是關於建築的一個大問題,但我找不到解決方案。 – Vladislav
我繼續用傳輸大數據測試速度。使用「Chunks」方法,我可以發送300 000(!)行,在4.34分鐘內將其保存到數據庫,而不會對我的服務配置做任何更改。我只是將我的數據分爲50行的塊。 – Vladislav
您應該使用Datacontract Serializer代替XML。這是迄今爲止reference.cs中的手動替換作業。 – NickD