web service proxy setting
Asked Answered
A

4

6

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?

Alyssaalyssum answered 5/3, 2011 at 17:1 Comment(1)
What type does ManufacturerContactDetailsWebServiceSoapClient derives from?Touristy
D
9

Create the app config file containing the following

<system.net>
    <defaultProxy useDefaultCredentials="true">
        <proxy usesystemdefault="True" bypassonlocal="True"/>
    </defaultProxy>
</system.net>

More info here http://blogs.infosupport.com/blogs/porint/archive/2007/08/14/Configuring-a-proxy_2D00_server-for-WCF.aspx

Bye

Disjoint answered 5/3, 2011 at 17:14 Comment(0)
T
9

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");
}
Touristy answered 5/3, 2011 at 17:12 Comment(0)
D
9

Create the app config file containing the following

<system.net>
    <defaultProxy useDefaultCredentials="true">
        <proxy usesystemdefault="True" bypassonlocal="True"/>
    </defaultProxy>
</system.net>

More info here http://blogs.infosupport.com/blogs/porint/archive/2007/08/14/Configuring-a-proxy_2D00_server-for-WCF.aspx

Bye

Disjoint answered 5/3, 2011 at 17:14 Comment(0)
L
7

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>
Leadin answered 26/9, 2011 at 6:48 Comment(1)
Worked great. For pushing traffic through Fiddler, here's the line we used: <proxy proxyaddress="http://127.0.0.1:8888"/>Bouillabaisse
I
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.

Implant answered 5/3, 2011 at 17:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.