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

妖精的绣舞 提交于 2019-12-12 05:27:25

问题


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?


回答1:


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.


来源:https://stackoverflow.com/questions/13055386/define-outgoing-calling-port-for-soap-web-service-in-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!