Question

Ok folks .. heres the deal -->

I have consumed a web-service in my console app and am able to successfully invoke the same when running from my local machine.

Trouble brews when I deploy the app on my Win 2K8 box. I first came up on -> The remote name could not be resolved: 'www.www.net' -> and so I added a WebProxy and hooked it up to the .Proxy property of the web-service.

The next error I have run into is -> The request failed with HTTP status 407: authenticationrequired. And I am at a loss of ideas to resolve the same.

I have used --> .Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; and have also explicitly defined proxy creds -> username, password, domain --> but to no avail

The web-service works fine when accessed over a browser from within the server.

Any help would be highly appreciated.

Thanks for your time.

Rgds,

Was it helpful?

Solution 2

Ok .. heres what got it working finally -->

Got in touch with the NOC (network) guys - and they in turn turned on an explicit IP-based access to requests/response to/from the server.

Will that result in a security breach - well I am not sure.

Rgds,

OTHER TIPS

Are you behind a proxyserver? Does your browser have a proxy server configured? 407 means "Proxy Authentication Required", so you need to provide credentials with which you can authenticate on the proxy server. My first guess is you need someting like this.

  var credentials = new NetworkCredential("username", "password", "domain");
  WebProxy proxy = new WebProxy("YourProxyServerUri", true) { Credentials = credentials };

And then you should use te proxy object as Proxy server for your webservice.

You can also use the systems configured proxy server:

  WebProxy myProxy = (WebProxy) System.Net.HttpWebRequest.GetSystemWebProxy();

Or you could even set it up in web.config (but i think it's not possible to provide credentials here:

 <system.net> 
      <defaultProxy useDefaultCredentials="true"> 
         <proxy usesystemdefault="False" proxyaddress="YourProxyServerUri"                
          bypassonlocal="True" /> 
      </defaultProxy> 
 </system.net>

If all works fine, you may want to provide some way to configure the proxyserver and credentials at runtime, from outside your code. Otherwise you always have to recompile things if something in your production environment or location changes. You can put this in your appSettings section in web.config, in a database, app.config etc..

Also be sure you provide the right port number in your settings (for example 192.168.1.100:8888)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top