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.
Asked
Active
Viewed 768 times
5
-
Web Reference or Service Reference? – John Saunders Dec 27 '11 at 04:14
2 Answers
2
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);
}
}

John Saunders
- 160,644
- 26
- 247
- 397
0
In WCF when you create your ChannelFactory you can specify your endpoint (or IP address to which you wish to connect).
Dim factory As ChannelFactory(Of IChatServiceChannel)
factory = New DuplexChannelFactory(Of IChatServiceChannel)(callbackObject, binding, endpoint)
Dim Channel = factory.CreateChannel()
You can connect to as many different IPs as you want like this by specifying different endpoints.

John Saunders
- 160,644
- 26
- 247
- 397

RyanFishman
- 695
- 5
- 13
-
not the end point but the starting point for SOAP request initialization. @RyanFishman – Akhil K Nambiar Dec 28 '11 at 08:10
-
1Besides, he says he's using a web reference, so he can't use your technique. – John Saunders Dec 28 '11 at 08:15