Web Service HTTP-407 Proxy Access Denied Error
February 12, 2008
Summary
When calling a web service operation you get the following error: “The request failed with HTTP status 407: Proxy Access Denied.”Conditions:
- When you inspect System.Security.Principal.WindowsIdentity.GetCurrent() the returned WindowIdentity is the current user’s Windows account.
- The web service proxy’s Proxy is null: “webService.Proxy == null” I true.
- The web service’s Credentials might be set or not. You get the above error even though you’ve set the web service proxy’s Credentials from System.Net.CredentialCache.DefaultCredentials: “webService.Credentials = System.Net.CredentialCache.DefaultCredentials”.
Solution
If the web service proxy’s Proxy property is null, then assign the default WebProxy to it:
if ( webService.Proxy == null )
{
webService.Proxy = System.Net.WebProxy.GetDefaultProxy();
webService.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
}






April 28, 2008 at 4:12 pm
The problem with this method is that Microsoft says it is already obsolete but has raised no concrete solution, does not indicate how they replace.
April 29, 2008 at 7:43 am
@José:
I solved this problem for .NET 1.1, so I can’t comment on the issue for .NET versions after that. I will do an updated post for .NET 2 & 3 when I need to solve it for those frameworks, or please let me know if you find the solution to this problem on those frameworks. I will update the post, and give you full credit. Thanks for letting us know that it was made obsolete for other .NET frameworks.
July 30, 2008 at 7:17 am
I’ve solved this issue creating a new proxy. Thank you for this post, has helped me a lot.
if ( webService.Proxy == null )
{
webService.Proxy = new WebProxy();
webService.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
}
July 30, 2008 at 5:54 pm
@Dani: Cool! Glad to have pointed you in the correct direction.
October 16, 2009 at 12:47 pm
Thankx for ur help it have solved my access problem