2010-02-03 192 views
0

因此,我们拥有控制台托管的WCF服务和ASP.NET Web服务(在IIS上)。 经过一些艰难的操作后,WCF服务必须将一些(大型)数据返回给ASP.NET Web服务以进行下一步处理。我测试的结果很小,一切都很好。 但是,在对4.5 MB附近的序列化结果对象的真实数据进行测试之后,ASP.NET Web服务(它是wcf-client-server通信中的客户端)发生错误。从WCF服务返回大量数据到ASP.NET Web服务

这是我得到的错误:

套接字连接被中止。这可能是由于处理您的消息的错误 或远程主机的 接收超时或基础网络资源问题所致。本地套接字 超时时间为'04:00:00'。内异常:SocketException:“一个现有 连接被强行关闭远程主机”错误码= 10054

消息大小由下一个绑定配置(在服务器和客户端):

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属性在配置文件中配置。

你能告诉我什么?另外我还需要示例如何以编程方式在客户端和服务器上设置MaxObjectsInGraph属性。

感谢您的回答。

回答

0

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