1.设置最大序列化集合元素个数
factory = new ChannelFactory<TClient>(binding, serviceAddress);
proxy = factory.CreateChannel();
//设置最大集合返序列化数目
foreach (var opt in factory.Endpoint.Contract.Operations)
{
opt.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = 1000000;
opt.Behaviors.Find<DataContractSerializerOperationBehavior>().IgnoreExtensionDataObject = true;
}
-------------------------------------------------
2.NO SVC
3.添加SOAP请求头
using (var scope = new OperationContextScope(((IClientChannel)proxy))) {
ServiceLocator.AttachHeader(proxy);
var list = proxy.GetAccountList();
Console.WriteLine("i:" + i + "," + list.Count);
}
//必须释放scope 因为scope会关联到线程,不释放会一直占用内存