是否可以使用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);
我尝试使用上面的代码但不起作用。看起来像BindIPEndpointDelegate在调用oChannelFactory.CreateChannel()后进入无限循环。