My blog has moved and can now be found at http://blog.aniljohn.com

No action is needed on your part if you are already subscribed to this blog via e-mail or its syndication feed.

Thursday, January 19, 2006
« Time: The Limiting Factor to Accomplishm... | Main | The Accident »

I recently had the need to consume a web service that required that I authenticate against a HTTP Proxy. The credentials required for authentication against the proxy were NOT my default login credentials but an explicit user-name/password that was provided by the proxy owner.

Here is the working C# code used by the service consumer:

_ws.Url = "http://url.tothe.webservice";
if (_useProxy)
{
	System.Net.WebProxy _wp = new WebProxy(_proxyUri);
	System.Net.NetworkCredential _creds = 
                           new NetworkCredential(_proxyUsername,_proxyPassword);
	System.Net.CredentialCache _cache = new CredentialCache();
	_cache.Add(new Uri(_proxyUri),"Negotiate", _creds);
_ws.Proxy = _wp; _ws.Proxy.Credentials = _creds; }

Where _ws is my web service proxy class and _proxyUri is the Uri of the proxy server and is in the "the.proxy.server:8000" format.

[Now playing: Chaiyya Chaiyya - Dil Se]

1/19/2006 7:32 PM Eastern Standard Time  |  Comments [0]  |  Disclaimer  |  Permalink    Tracked by:
"Link Listing - January 20, 2006" (Christopher Steen) [Trackback]
Comments are closed.