Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a webservice from behind a proxy server

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.

like image 794
Hemant Avatar asked May 13 '09 17:05

Hemant


1 Answers

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:

  <system.net>
    <defaultProxy>
      <proxy  proxyaddress="http://yourproxyserver:80" />
    </defaultProxy>
  </system.net>

You could also do it through code using this:

WebRequest.DefaultWebProxy = new WebProxy("http://yourproxyserver:80/",true);
like image 149
AaronS Avatar answered Oct 27 '22 09:10

AaronS