Search code examples
wcfweb-servicesproxyisaserverhttp-status-code-407

WCF Client - 407 Proxy Authentication Required while running webservice


I've created simple WinForms app that uses free webservice http://www.webservicemart.com/uszip.asmx. But this app fails to use service operation with error:

The remote server returned an unexpected response: (407) Proxy Authentication Required (The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied)

Code that creates proxy and triggers service operation:

ChannelFactory<ServiceReference1.USZipSoap> proxy = new ChannelFactory<ServiceReference1.USZipSoap>("USZipSoap");
ServiceReference1.USZipSoap client = proxy.CreateChannel();
string str = client.ValidateZip("12345");
MessageBox.Show(str);

Is this problem with a network of my company or this is a proxy on the side of webservicemart.com?

I've googled a lot of information on changing configuration files, creating a custom binding, etc. But I feel the lack of more basic understanding...
If this error is about ISA server of our corporate network then what configuration should I make to ISA Server to not restrict me from using external webservices?


Solution

  • In your binding configuration make sure that useDefaultWebProxy is set to true - it will use configuration you have found in IE. In your configuration file add following snippet to ensure default your credentials are used for authentication on the proxy server:

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