Vb.net 从特定IP地址发送SOAP请求
我有一个多IP地址的系统。但我只允许从一个IP地址发起SOAP请求。如何在VB.NET中获得该值。在WCF中创建ChannelFactory时,可以指定要连接的端点(或IP地址)Vb.net 从特定IP地址发送SOAP请求,vb.net,soap,asmx,Vb.net,Soap,Asmx,我有一个多IP地址的系统。但我只允许从一个IP地址发起SOAP请求。如何在VB.NET中获得该值。在WCF中创建ChannelFactory时,可以指定要连接的端点(或IP地址) 通过指定不同的端点,您可以像这样连接到任意多个不同的IP。我从来没有这样做过。看起来很复杂 首先,阅读以了解覆盖代理类的GetWebRequest对象的基本技术 您需要覆盖GetWebRequest,以便获取用于发出请求的ServicePoint。您将属性设置为指向您的方法的委托,该方法将返回正确的IP地址 publi
通过指定不同的端点,您可以像这样连接到任意多个不同的IP。我从来没有这样做过。看起来很复杂 首先,阅读以了解覆盖代理类的
GetWebRequest
对象的基本技术
您需要覆盖GetWebRequest
,以便获取用于发出请求的ServicePoint
。您将属性设置为指向您的方法的委托,该方法将返回正确的IP地址
public partial class Service1
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = (HttpWebRequest) base.GetWebRequest(uri);
request.ServicePoint.BindIPEndPointDelegate = ReturnSpecificIPAddress;
return request;
}
private IPEndPoint BindIPEndPoint(
ServicePoint servicePoint,
IPEndPoint remoteEndPoint,
int retryCount)
{
return new IPEndPoint(IPAddress.Parse("10.0.0.1"), 80);
}
}
Web引用或服务引用?不是SOAP请求初始化的终点,而是起点@Ryanfishman此外,他说他在使用网络参考,所以他不能使用你的技术。
public partial class Service1
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = (HttpWebRequest) base.GetWebRequest(uri);
request.ServicePoint.BindIPEndPointDelegate = ReturnSpecificIPAddress;
return request;
}
private IPEndPoint BindIPEndPoint(
ServicePoint servicePoint,
IPEndPoint remoteEndPoint,
int retryCount)
{
return new IPEndPoint(IPAddress.Parse("10.0.0.1"), 80);
}
}