I need to consume a WCF service but I'm behind a proxy server and this proxy server requires a username and password.
I can't find a way to set it, if it was a Web Service, I could just do something like
ws.Proxy = myProxyServer;
How can I do this with a WCF service?
In the WCF binding config, use the useDefaultWebProxy property to make WCF use the windows default proxy (which can be set from IE network config):
Then in the code, before you use the connection, do this:
and with your webrequest object, before you execute the call:
I have not tested the code, but I believe this should work.
Note replaced previous answer based on comment
There was actually another stackoverflow answer that covered setting credentials on a proxy.
Is it possible to specify proxy credentials in your web.config?