web service proxy setting

33,383

Solution 1

If this is a WCF client there is no Proxy property. You could try this instead:

var proxy = new WebProxy("proxy.foo.com", true);
proxy.Credentials = new NetworkCredential("user", "pass");
WebRequest.DefaultWebProxy = proxy;

and then do the call:

using (var ws = new ManufacturerContactDetailsWebServiceSoapClient())
{
    var cd = ws.GetContactDetails("Google");
}

Solution 2

Add this to your app.config or web.config:

<system.net>
  <defaultProxy enabled="true">
    <proxy proxyaddress="http://111.222.333.444:80"/>
  </defaultProxy>
</system.net>

Solution 3

Try adding this to app.config file.

<system.net> 
    <defaultProxy enabled="false" useDefaultCredentials="false"> 
        <proxy/> 
    </defaultProxy> 
</system.net> 

Add proxy in the proxy tag. Use the default proxy tag in the system.net setting in the app.config.

Share:
33,383
Fidel
Author by

Fidel

Updated on August 04, 2022

Comments

  • Fidel
    Fidel over 1 year

    In c# 4.0, I have a web service called ManufacturerContactDetails. I am calling that web service from a windows app using the following:

    var ws = new ManufacturerContactDetailsWebServiceSoapClient();
    ContactDetails cd = ws.GetContactDetails("Google");
    

    However, I would like to set the web proxy server that the soap client uses. I've had a look for a ws.Proxy property but it doesn't exist. I don't want to use the one from internet explorer.

    How do I set the web proxy server to use?