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]
br>