[英]WCF And Large Amounts Of Data
I want to be able to send large amount of data to my WCF service
, what i am sending is List<byte[]>
that the client received and currently my application get an error that socket aborted. 我希望能够向
WCF service
发送大量数据,我发送的是客户端收到的List<byte[]>
,当前我的应用程序收到套接字中止的错误。
so i found ths thread: http://geekswithblogs.net/tmurphy/archive/2011/08/15/sending-large-arrays-with-wcf.aspx 所以我找到了这个线程: http : //geekswithblogs.net/tmurphy/archive/2011/08/15/sending-large-arrays-with-wcf.aspx
this is how my connection is estanlished: 这是建立我的联系的方式:
string urlService = "net.tcp://localhost:8000/myApp";
ServiceHost host = new ServiceHost(typeof(pp.classes.service1));
host.Opening += new EventHandler(host_Opening);
host.Opened += new EventHandler(host_Opened);
host.Closing += new EventHandler(host_Closing);
host.Closed += new EventHandler(host_Closed);
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial
pp.classes.service1 ser = new pp.classes.service1();
host.AddServiceEndpoint(typeof(pp.classes.IService1), tcpBinding, urlService);
ServiceMetadataBehavior metadataBehavior;
metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metadataBehavior == null)
{
// Create the proxy object that is generated via the svcutil.exe tool
metadataBehavior = new ServiceMetadataBehavior();
metadataBehavior.HttpGetUrl = new Uri("http://localhost:8001/myApp");
metadataBehavior.HttpGetEnabled = true;
metadataBehavior.ToString();
host.Description.Behaviors.Add(metadataBehavior);
string urlMeta = metadataBehavior.HttpGetUrl.ToString();
}
host.Open();
I try to find maxReceivedMessageSize
, maxStringContentLength
and maxArrayLength
properties but i found only maxReceivedMessageSize
(i am working without app.config file) 我尝试找到
maxReceivedMessageSize
, maxStringContentLength
和maxArrayLength
属性,但是我只找到maxReceivedMessageSize
(我没有app.config文件)
Use this config in code. 在代码中使用此配置。 It will set the reader quotas to the max:
它将读取器配额设置为最大值:
XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
quotas.MaxDepth = 2147483647;
quotas.MaxStringContentLength = 2147483647;
quotas.MaxArrayLength = 2147483647;
quotas.MaxBytesPerRead = 2147483647;
quotas.MaxNameTableCharCount = 2147483647;
tcpBinding.ReaderQuotas = quotas;
Set the timeout using this. 使用此设置超时。 It will set the timeout to 5 minutes.
它将超时设置为5分钟。
tcpBinding.ReceiveTimeout = new TimeSpan(0, 5, 0);
tcpBinding.SendTimeout = new TimeSpan(0, 5, 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.