The request failed with HTTP status 401:Unauthorized.

Recently I wanna practice some web service program. I stucked at one error The request failed with HTTP status 401:Unauthorized. .

I had set up the credential in my code like following, so my program should have right to excute

        Dim objWS As New SoapHeaderTestWS.Service1
        Dim objWSHeader As New SoapHeaderTestWS.HeaderClass
        Dim credCache As New CredentialCache
        credCache.Add(New Uri(objWS.Url), "Basic",  _
                                                        New NetworkCredential("Administrator", "pass@word1"))                            
        objWS.Credentials = credCache

however i still have "HTTP status 401:Unauthorized. ." error.

I found my problem is in IIS setting. I had to check "Basic authentication(password is sent in clear text)".

I guess the reason is simple, because I use "Basic"  authentication type in my code.
So I have to configue my webserivice in IIS to correspond with my code.
             

转载于:https://www.cnblogs.com/yangbin990/archive/2006/11/21/567619.html

你可能感兴趣的:(The request failed with HTTP status 401:Unauthorized.)