D. Dubya
D. Dubya

Reputation: 189

Define Outgoing/Calling Port for SOAP Web Service in Visual Studio 2010

The application application I'm currently working on is required to interface with a web service using SOAP. The service providers want to restrict access to the service via a firewall using BOTH an IP address and a Port. I'm using VS 2010 and the service has been added as a .NET 2.0 Web Service.

Right now the firewall rule for my connection's port is set to 'ANY' and the service team wants to tighten it down to a specific port. I can't seem to find any way to set a specific outgoing port (port used when exiting my web server) in my service.

Is it even possible to do this?

Upvotes: 0

Views: 1549

Answers (1)

John Saunders
John Saunders

Reputation: 161821

It is possible to do this, but it's a non-trivial customization.

  1. See Ways to Customize your ASMX Client Proxy for the general techniques. Near the bottom, you'll find "Heavy-Duty Customization".
  2. By overriding the GetWebRequest method, you can gain access to the HttpWebRequest instance being used by the request.
  3. HttpWebRequest has a ServicePoint property.
  4. ServicePoint has a BindIPEndPointDelegate property.
  5. Set this property to point to a method that will decide which IP address and port to use.

Upvotes: 1

Related Questions