Freigeben über


Unauthorized or AccessDenied exception when using SOAP Native Xml Web Services

One of the common problems people face when using SQL 2005 web services for the first time is the requirement of specifying credentials in the SOAP request.  Unlike .Net Framework web services, where the server may not require credentials, SQL 2005 has a strict rule that credentials must be specified.

If your client application was developed using C# and you see the following exception:
   System.Net.WebException
The request failed with HTTP status 401: Unauthorized.

This means that the client application is not sending any credentials or the credentials are wrong (ie. old password).

To correct the problem, specify the correct credentials to be used.  The simplest way is to specify
   proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
in the C# code, where "proxy" is the variable of the web service class.

Additional information regarding how to specify the exact type of authentication scheme to use (ie. Digest, Kerberos, or NTLM) in a C# application is available in Books Online under topic "Specifying Non-Kerberos Authentication in Visual Studio Projects".  This topic is reachable through the index by looking for "Native XML Web Services"->"writing client applications".

If your client application was developed using C# and you see the following exception:
   System.Web.Services.Protocols.SoapException
There was an error in the incoming SOAP request packet: Client, LoginFailure, AccessDenied

This means that the user credential you specified does not have permission to connect to the endpoint or to execute the specific web method.

To correct the problem, grant the necessary permissions to the objects related to the request (ie. Connect permissions to the endpoint; execute permissions on the stored procedure; select permissions on the table; execute permissions CLR UDT; etc.)

Jimmy Wu, SQL Server Protocols
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights

Comments

  • Anonymous
    August 03, 2006
    Thank you.  This helped a bunch

  • Anonymous
    September 04, 2006
    Hi
    Iam getting  System.Web.Services.Protocols.SoapException
      There was an error in the incoming SOAP request packet:  Client, LoginFailure, AccessDenied for ASP.net application while calling a SQL server 2005 on the local machine
    .But the same code went thro when i used froms based c# client .
    If possible pls do explain on this.

    Thanks and Regards
    Sezhian.gk

  • Anonymous
    September 05, 2006
    The comment has been removed

  • Anonymous
    September 09, 2006
    The comment has been removed

  • Anonymous
    January 16, 2007
    The comment has been removed

  • Anonymous
    January 17, 2007
    The comment has been removed

  • Anonymous
    January 04, 2008
    PingBack from http://famousquotes.247blogging.info/?p=409

  • Anonymous
    April 10, 2008
    The comment has been removed

  • Anonymous
    October 23, 2008
    I am using this and it works for me.  The point here is that we need to include "System.Net.ICredentials credentials = new System.Net.NetworkCredential("userIdxxx", "Passwordxxx", "domainxxx")"; com.abcCompany.Project1.account_endpoint objProxy = new com.clickable.eds.business_endpoint(); System.Net.ICredentials credentials = new System.Net.NetworkCredential("userIdxxx", "Passwordxxx", "domainxxx"); objProxy.Credentials = credentials; Object objData = objProxy.GetBalanceSheet();

  • Anonymous
    May 12, 2009
    The comment has been removed