keyongtech


  keyongtech > dotnet.framework.aspnet.* > dotnet.framework.aspnet.main > 02/2006

 #1  
02-17-06, 03:55 AM
ad
I have a WebService in localhost, and the set in the web.config is

<add key="WebReference.Service"
value="http://localhost/HealthService/Service.asmx"/>
and the code to refer the WebService is
WebReference.Service wsHealth = new WebReference.Service();

But when I use code to execute a function in the webservice, like
ds =(System.Data.DataSet)wsHealth.GetSchools_Zip(txtZ ip1.Text);

it result into an error:
The request failed with HTTP status 401: Unauthorized


I have type the web service URL into browse, it execute OK, but it can't
call in program.

How can I do?
 #2  
02-17-06, 05:11 PM
Brock Allen
Sounds like IIS is using integrated authentication for that application.
Your browser supplies the credentials of the logged in user, whereas the
web service proxy does not. You can either change the code for your web service
proxy to 1) hard code the credntials, 2) prompt the user and pass those credentials,
or 3) use the current logged in user's credentials. Check out the Credentials
property of teh web service proxy. Set it to CredentialCache.DefaultCredentials
to get the thrid behavior I listed. For the first or second, use an instance
of the System.Net.NEtworkCredential class.

-Brock
[url down]
[..]
 #3  
02-18-06, 12:11 AM
ad
Thanks,
I use the method 3, and my problem is gone away.
But I have some question:

I have set virtual directory of the WebService to anonymous, why it need
Credentials ?



"Brock Allen" <ballen>
???????:b8743b137ec8c801d25aa07ac2...
[..]
Similar Threads
The request failed with HTTP status 401: Unauthorized

I'm trying to login to the report manager. I have a custom security extension that has been working for the last year. All of a sudden it stopped working on our...

The request failed with HTTP status 401: Unauthorized.

Has anyone experienced this message when attempting to consume a Sharepoint Web Service? I have seen many posts with many suggestions, but I have not been able to get beyond...

The Request Failed with HTTP status 401 Unauthorized

Hi, We have integrated our portal developed in ASP.NET 2.0 with MS CRM 3.0 using the web services exposed by CRM. We are able to insert the records successfully in Account...

The request failed with HTTP status 401: Unauthorized.

Hello, I am using the web service posted by MS under this link [..] to upload a file to a document library. Sharepoint is on a remote machine. I am getting the this error...

The request failed with HTTP status 401: Unauthorized.

Hello, I came in today and when we goto [..] It asks for a domain login and then we get "The request failed with HTTP status 401: Unauthorized." The security hasn't changed....


All times are GMT. The time now is 01:30 AM. | Privacy Policy