Web Service HTTP-407 Proxy Access Denied Error

When calling a web service operation you get the following error: “The request failed with HTTP status 407: Proxy Access Denied.”Conditions:

  1. When you inspect System.Security.Principal.WindowsIdentity.GetCurrent() the returned WindowIdentity is the current user’s Windows account.
  2. The web service proxy’s Proxy is null: “webService.Proxy == null” I true.
  3. 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”.

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;


6 Comments on “Web Service HTTP-407 Proxy Access Denied Error”

  1. José Dunstan says:

    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.

  2. openlandscape says:

    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.

  3. Dani says:

    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;

  4. openlandscape says:

    @Dani: Cool! Glad to have pointed you in the correct direction.

  5. Rahat says:

    Thankx for ur help it have solved my access problem

  6. namratha says:

    that works…. 😉
    thanks fr help

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s