15

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Alexander Serdyuk
  • 175
  • 1
  • 2
  • 6
  • 1
    Yes it is problem with proxy in your local network. Show your binding configuration and also check if you have proxy configured in Internet Explorer. – Ladislav Mrnka Jan 04 '12 at 09:02
  • I just prepared my configuration but it was too large to fit comment size and I've faced with restriction saying that I cannot answer my own questions.
    But anyway... I really have proxy configured in my browser settings.
    I'v got some progress after I changed useDefaultWebProxy from true to false. And now I have EndpointNotFoundException with message "There was no endpoint listening at http://www.webservicemart.com/uszip.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details."
    – Alexander Serdyuk Jan 04 '12 at 12:27
  • And InnerException of type System.Net.WebException with message "The remote name could not be resolved: 'www.webservicemart.com'" – Alexander Serdyuk Jan 04 '12 at 12:29
  • If you want to add some details to your question (like configuration) you must edit the question and not pass it as comment or answer. – Ladislav Mrnka Jan 04 '12 at 13:36

5 Answers5

43

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>
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
2

This worked for me... replacing 10.1.0.50 and the port number with your proxy server's IP

  <system.net>
    <defaultProxy useDefaultCredentials="true">
      <proxy usesystemdefault="False" proxyaddress="http://10.1.0.50:8080" bypassonlocal="True" />
    </defaultProxy>
  </system.net>
JGilmartin
  • 8,683
  • 14
  • 66
  • 85
1

Seems like all the traffic in your company is being redirected through a proxy. Can you browse to the web service from your IE and see its wsdl and invoke the test page to see some results. If that is the case then try adding the below section into your web.config:

<system.net>   
<defaultProxy>     
<proxy proxyaddress="<your proxy address>" bypassonlocal="true" />
</defaultProxy>
</system.net> 

You can find the proxy address from the settings of your IE.

NOTE: When you move to different environments then you need to make sure that its the same case else you need to remove the above configuration.

Rajesh
  • 7,766
  • 5
  • 22
  • 35
  • Thank you very much for reply. I've just made some progress in solving this problem. I have changed useDefaultWebProxy from true to false and after that it seems like I've passed my proxy authentication. But I still have another exceptions saying that "There was no endpoint listening at http://www.webservicemart.com/uszip.asmx that could accept the message." I have also tried another free webservice and just received exactly the same error. – Alexander Serdyuk Jan 04 '12 at 12:32
  • I have tried accessing the above web service and it works fine. If you need help just post some more update and can try helping you out. – Rajesh Jan 04 '12 at 12:35
0

You can set the web.config of the service to allow to use the proxy settings as defined in Internet Explorer.

skzi
  • 340
  • 3
  • 14
0

Sometime in the future.

WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
Krishneil
  • 1,432
  • 1
  • 18
  • 26