Error HTTP status 401: Access Denied.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Error HTTP status 401: Access Denied.

  1. #1
    MV Guest

    Error HTTP status 401: Access Denied.


    Hi,

    I created 2 web services with VB.NET. When I test them in the
    automatically-generated aspx page, there's no problem.

    However, when I try to call them from a program, I get the following error:
    The request failed with HTTP status 401: Access Denied.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The request failed with HTTP
    status 401: Access Denied.
    --
    When I turn on the trace I get this info:
    Line 69:
    System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.or
    g/BrowseDestinations",
    Use:=System.Web.Services.Description.SoapBindingUse.Literal,
    parameterstyle:=system.web.services.protocols.soapparameterstyle.wrapped)>
    _
    Line 70: Public Function BrowseDestinations(ByVal StartDate As
    String, ByVal EndDate As String, ByVal Categories As String) As
    System.Data.DataSet
    -->Line 71: Dim results() As Object =
    Me.Invoke("BrowseDestinations", New Object() {StartDate,
    EndDate,Categories})
    Line 72: Return CType(results(0),System.Data.DataSet)
    Line 73: End Function
    --
    The Line 71 raise the authentication error. This piece of code corresponds
    to the proxy that VS.NET generates for the web service.

    As you can see this is a security error caused by the automatically-generated
    proxy and to be honest with you people, I
    would be needing the 'Complete Idiot Guide' to solve it as I'm a newbie when
    it comes to set access permitions in Windows 2000.

    I have both anonymous access and integrated Windows auth checked for the
    web directory hosting my web services.

    Do i have to change wy config.web or anything like that?

    Thanks in advance for any help


  2. #2
    Meg Guest

    Re: Error HTTP status 401: Access Denied.


    I have the exact same problem! I was just doing the walkthrough (Accessing
    A Web Service).

  3. #3
    Meg Guest

    Re: Error HTTP status 401: Access Denied.


    MV,

    Try unchecking Integrated Windows Authentication in your Directory Security
    settings. It worked for me. : )


  4. #4
    Tsafi Guest

    Re: Error HTTP status 401: Access Denied.


    I have exactly the same problem. I receive the 401 http error while doing
    the walkthrough "Accessing an XML Web Servive using visual Basic or Visual
    C#" (I did it with C#).

    I tried to uncheck the "Integrated Windows Authentication" option in IIS
    but it didn't work!


    Here is the error I received from the Web Service:

    Server Error in '/TempConvertClient2' Application.
    --------------------------------------------------------------------------------

    The request failed with HTTP status 401: Access Denied.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information about
    the error and where it originated in the code.

    Exception Details: System.Net.WebException: The request failed with HTTP
    status 401: Access Denied.

    Source Error:


    Line 35: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://Walkthrough/XmlWebServices/ConvertTemperature",
    RequestNamespace="http://Walkthrough/XmlWebServices/", ResponseNamespace="http://Walkthrough/XmlWebServices/",
    Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    Line 36: public System.Double ConvertTemperature(System.Double dFahrenheit)
    {
    Line 37: object[] results = this.Invoke("ConvertTemperature",
    new object[] {
    Line 38: dFahrenheit});
    Line 39: return ((System.Double)(results[0]));


    Source File: c:\inetpub\wwwroot\TempConvertClient2\Web References\ConvertSvc\Reference.cs
    Line: 37

    Stack Trace:


    [WebException: The request failed with HTTP status 401: Access Denied.]
    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
    message, WebResponse response, Stream responseStream) +1174
    System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,
    Object[] parameters) +216
    TempConvertClient2.ConvertSvc.Service1.ConvertTemperature(Double dFahrenheit)
    in c:\inetpub\wwwroot\TempConvertClient2\Web References\ConvertSvc\Reference.cs:37
    TempConvertClient2.WebForm1.Button1_Click(Object sender, EventArgs e)
    in c:\inetpub\wwwroot\tempconvertclient2\webform1.aspx.cs:54
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(St ring
    eventArgument) +58
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,
    String eventArgument) +18
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain() +1263




    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET
    Version:1.0.3705.0




  5. #5
    Tsafi Guest

    Re: Error HTTP status 401: Access Denied.


    The following solution, by Matt Griffith, worked for me:

    You need to set the Credentials property of your service. To pass the
    system credentials for the current security context, you can use
    CredentialCache.DefaultCredentials.

    For a service named SimpleService, it would look something like this:

    [C#]
    SimpleService ss = new SimpleService();
    ss.Credentials = System.Net.CredentialCache.DefaultCredentials;


    Tsafi




  6. #6
    Mike T Guest

    Re: Error HTTP status 401: Access Denied.


    The call to System.Net.CredentialCache.GetCredential by the underlying web
    services code will get a null w/o setting the value described below. That
    being the case, does anyone know why in every web service example I've seen
    this is never mentioned? Adding it works for both WinForm and ASP.NET as
    seems to be required in each. Anyone have any background why this is never
    mentioned since this is so critical to making web service calls work.

    Thanks!

    "Tsafi" <tmeir@ndsisrael.com> wrote:
    >
    >The following solution, by Matt Griffith, worked for me:
    >
    >You need to set the Credentials property of your service. To pass the
    >system credentials for the current security context, you can use
    >CredentialCache.DefaultCredentials.
    >
    >For a service named SimpleService, it would look something like this:
    >
    >[C#]
    >SimpleService ss = new SimpleService();
    >ss.Credentials = System.Net.CredentialCache.DefaultCredentials;
    >
    >
    >Tsafi
    >
    >
    >



  7. #7
    Join Date
    Feb 2009
    Posts
    1

    the credentials

    changing the code for the credentials worked for me as well-what a relief.

    I had the equally difficult task of changing the code to VB

    Ta!
    Ade

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center