This one was causing my brain to melt…

In .NET 3.5, adding a Service Reference to a web service would automatically use the proxy server.  In .NET 4.0 something changed.  In 4.0, the call was failing with the error ‘The remote server returned an error: (407) Proxy Authentication Required.’  Trying to find the answer to this problem was a bit difficult as WCF 4.0 uses the term Proxy for the code proxies.  It took a bit, and the answer was dead simple…

Add the following code to the app.config or web.config file:

<system.net>
    <defaultProxy
      useDefaultCredentials="true">
    </defaultProxy>
</system.net>

This will tell .NET 4.0 to use the default credentials for the proxy server.

Doh!

Advertisements

One thought on “How to access a web service using WCF 4.0 behind a proxy firewall

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s