简体   繁体   English

将大数据从WCF服务返回到ASP.NET Web服务

[英]Return large data from WCF Service to ASP.NET Web Service

So we have console-hosted WCF Service and ASP.NET WEB Service (on IIS). 因此,我们有了控制台托管的WCF服务和ASP.NET WEB服务(在IIS上)。 After some tough operation WCF Service must return some (large) data to ASP.NET Web Service for next processing. 经过一些艰苦的操作后,WCF服务必须将一些(大)数据返回到ASP.NET Web服务进行下一步处理。 I tested on small results and everything is ok. 我测试了一些小结果,一切正常。 But after testing on real data that is a serialized result object that is near 4.5 MB, an error occurs on ASP.NET Web Service, which is the client in wcf-client-server communication. 但是,在对接近于4.5 MB的序列化结果对象的实际数据进行测试之后,ASP.NET Web服务(wcf-client-server通信中的客户端)发生错误。

This is the error I got: 这是我得到的错误:

The socket connection was aborted. 套接字连接已中止。 This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. 这可能是由于处理您的消息时出错,远程主机超出了接收超时或潜在的网络资源问题引起的。 Local socket timeout was '04:00:00'. 本地套接字超时为“ 04:00:00”。 Inner Exception: SocketException:"An existing connection was forcibly closed by the remote host" ErrorCode = 10054 内部异常:SocketException:“远程主机强行关闭了现有连接” ErrorCode = 10054

Messages size are configured by next binding (on server and client): 消息大小由下一个绑定(在服务器和客户端上)配置:

NetTcpBinding netTcpBinding = new NetTcpBinding();
netTcpBinding.TransactionFlow = true;
netTcpBinding.SendTimeout = new TimeSpan(0, 4,0, 0);
netTcpBinding.Security.Mode = SecurityMode.None;
netTcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
netTcpBinding.Security.Transport.ProtectionLevel = ProtectionLevel.None;
netTcpBinding.MaxReceivedMessageSize = 2147483647;
netTcpBinding.MaxBufferSize = 2147483647;
netTcpBinding.MaxBufferPoolSize = 0;
netTcpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
netTcpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
netTcpBinding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
netTcpBinding.ReaderQuotas.MaxDepth = 32;
netTcpBinding.ReaderQuotas.MaxNameTableCharCount = 16384;

MaxObjectsInGraph property is configured in a config file. MaxObjectsInGraph属性在配置文件中配置。

What can you advise me? 你能给我什么建议? And also I need example how programmatically set MaxObjectsInGraph property on client and server. 另外,我还需要示例如何以编程MaxObjectsInGraph在客户端和服务器上设置MaxObjectsInGraph属性。

Thanks for answers. 感谢您的回答。

通过以编程方式将MaxObjectsInGraph(用于序列化程序)设置为服务属性可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM