Proxy Authentication for WCF Service

I need to use the WCF service, but I am behind the proxy server, and this proxy server requires a username and password.

I can’t find a way to install it, if it's a web service, I could just do something like

ws.Proxy = myProxyServer;

How can I do this using the WCF service?

+5
source share
2 answers

In the WCF binding configuration, use the useDefaultWebProxy property to force WCF to use the default Windows proxy (which can be set from the IE network configuration):

<bindings>
<basicHttpBinding>
<binding name="ESBWSSL" ...everything...  useDefaultWebProxy="true">

Then, in code before using the connection, do the following:

WebProxy wproxy = new WebProxy("new proxy",true);
wproxy.Credentials = new NetworkCredential("user", "pass");

and with your webrequest object before making the call:

WebRequest.DefaultWebProxy = wproxy;

I have not tested the code, but I think this should work.

+7

stackoverflow, -.

- web.config?

0

All Articles