I have a system with multiple IP address. But I'm allowed to initiate SOAP Request only from one IP address. How do I obtain that in VB.NET.
I've never done this. It looks complicated.
First, read Ways to Customize your ASMX Client Proxy to learn the basic technique of overriding the GetWebRequest
object of your proxy class.
You will need to override GetWebRequest
so that you can grab the ServicePoint
being used to make the request. You will set the BindIPEndPoint
property to a delegate pointing to a method of yours which will return the correct IP Address.
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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With