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
[2008 byte] By [
MV] at [2007-11-9 19:46:19]

# 1 Re: Error HTTP status 401: Access Denied.
I have the exact same problem! I was just doing the walkthrough (Accessing
A Web Service).
Meg at 2007-11-11 22:13:19 >

# 2 Re: Error HTTP status 401: Access Denied.
MV,
Try unchecking Integrated Windows Authentication in your Directory Security
settings. It worked for me. : )
Meg at 2007-11-11 22:14:14 >

# 3 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
Tsafi at 2007-11-11 22:15:12 >

# 4 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
Tsafi at 2007-11-11 22:16:22 >

# 5 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
>
>
>
Mike T at 2007-11-11 22:17:16 >
