C# – Calling a webservice from behind a proxy server

cnetsoapweb services

I need to add a functionality in an application (C#) which will use a web service (XML SOAP service).

Now this application can (and mostly) be used in an corporate environment which has a proxy server in place.

I understand the SOAP services use HTTP protocol and hence should use port 80, which is normally kept opened. Is it right that application can use web service without any special coding or I will need to write special code to detect proxy settings or some other issues you see?

EDIT: Webservice is a publicly available service on internet. Its not on same network.

Best Answer

It will use port 80 by default, and you shouldn't have to do any further coding.

If you do need to go through a proxy of some sort, all you need to do is add the following to your web.config:

      <proxy  proxyaddress="http://yourproxyserver:80" />

You could also do it through code using this:

WebRequest.DefaultWebProxy = new WebProxy("http://yourproxyserver:80/",true);
Related Topic