Fortunately there are a number of binding settings available in WCF to control your Http proxy usage. These settings are available directly on
WsHttpBinding (as well as on
HttpTransportBindingElement when you are using a
UseDefaultWebProxy(default == true): if set to true, will use the global value HttpWebRequest.DefaultProxy as your proxy. HttpWebRequest.DefaultProxy is controllable through System.Net config, and defaults to using the system proxy settings (i.e. when you see in your Internet Explorer properties).
ProxyAddress(default == null): If you want to specify a proxy directly you can set a proxy Uri directly here. To ensure no proxy is used you can specify â€œnullâ€ here. In both cases be sure to set UseDefaultWebProxy = false as well.
BypassProxyOnLocal(default == false): used in conjunction with ProxyAddress for when you specify a proxy. If you want “local” addresses (i.e. addresses on your intranet) to connect directly without using the proxy, set this value to
.ProxyCredentialType(default == None): Specifies the authentication mode used with your Http proxy. For custom bindings the equivalent setting is
ProxyAuthenticationScheme(default == Anonymous) on
HttpTransportBindingElement. For proxy authentication we will obtain the credential using the shared WCF provisioning framework (SecurityTokenProvider, etc). We simply pass in the proxy address (rather than the target address) for acquiring these credentials.
One last note about proxies: if you see a 502 or a 504 error returned to your client, then your client is using a proxy server. If this was not your intention, you can disable the server by setting
false, and using the default ProxyAddress of
null. The other possibility is that your proxy is misconfigured and you can use the above settings to rectify that situation 🙂