[英]Changing IPEndpoint of ChannelFactory in WCF connection
是否可以使用ServicePoint将客户端的传出IP地址更改为WCF服务?
var localIpAddress = IPAddress.Parse("192.168.1.113");
ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri(oDataSource.wcfURL));
servicePoint.BindIPEndPointDelegate =
(sp, rm, retryCount) =>
{
//Console.WriteLine(retryCount);
return new IPEndPoint(localIpAddress, 80);
};
DuplexChannelFactory<IBSPubSubService> oChannelFactory = new DuplexChannelFactory<IBSPubSubService>(new InstanceContext(this), oBinding, oEndpoint);
oPubSubClient = oChannelFactory.CreateChannel();
oPubSubClient.Faulted += new EventHandler(WcfFaultedListener);
oPubSubClient.Opened += new EventHandler(WcfOpenListener);
我尝试使用上面的代码,但不起作用。 似乎一旦调用oChannelFactory.CreateChannel(),BindIPEndpointDelegate就会进入无限循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.