我在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