12,162
社区成员
发帖
与我相关
我的任务
分享
EndpointAddress address = new EndpointAddress(pUrl);
Binding bindinginstance = null;
BasicHttpBinding ws = new BasicHttpBinding();
ws.MaxReceivedMessageSize = 20971520;
//ws.MaxBufferPoolSize = 99999999999;
//ws.MaxBufferSize = 999999999;
ws.Security.Mode = BasicHttpSecurityMode.None;
bindinginstance = ws;
using (ChannelFactory<T> channel = new ChannelFactory<T>(bindinginstance, address))
{
T instance = channel.CreateChannel();
using (instance as IDisposable)
{
try
{
Type type = typeof(T);
MethodInfo mi = type.GetMethod(pMethodName);//反射
return mi.Invoke(instance, pParams);
}
catch (TimeoutException)
{
(instance as ICommunicationObject).Abort();
throw;
}
catch (CommunicationException)
{
(instance as ICommunicationObject).Abort();
throw;
}
catch (Exception )
{
(instance as ICommunicationObject).Abort();
throw;
}
}
}