The request failed with HTTP status 401:Unauthorized.

本文描述了在实践WebService编程中遇到的HTTP状态401:未授权错误,并详细记录了解决过程。作者在代码中设置了凭据,但仍然收到错误。问题在于IIS设置,需要启用“基本身份验证”。文章强调了代码与Web服务配置的一致性对于避免此类错误的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

[root@controller ~]# tail -f /var/log/keystone/keystone.log 2025-03-04 00:04:10.596 12671 WARNING keystone.server.flask.application [req-1c53d976-a7a1-4f1e-87d9-79dcafb1c09d - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:17.469 12670 WARNING keystone.server.flask.application [req-fd7fc80d-27e0-46e8-a3f7-1c9144c85c1c - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:24.754 12667 WARNING keystone.server.flask.application [req-65436ff4-7a73-414b-94ac-1441bc602b5f - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:32.011 12670 WARNING keystone.server.flask.application [req-4348f851-0448-4232-a46e-3b18bd87e86a - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:39.006 12671 WARNING keystone.server.flask.application [req-40adc401-95ea-483b-b3a8-69de9bd7069f - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:45.920 12670 WARNING keystone.server.flask.application [req-8a3f78af-1eb0-46d6-a556-4d33aec8aafd - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:53.162 12667 WARNING keystone.server.flask.application [req-b313fefe-4b54-445c-bdb2-82201f9cec84 - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:04:59.945 12671 WARNING keystone.server.flask.application [req-8af88323-e340-46a8-8738-b4a25b201c0b - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:05:06.678 12669 WARNING keystone.server.flask.application [req-98ac090a-fe94-4222-b63e-436c1caf439f - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication. 2025-03-04 00:05:13.569 12668 WARNING keystone.server.flask.application [req-62c6f31a-1180-4d64-a1ce-62a0ee1ba03b - - - - -] Authorization failed. The request you have made requires authentication. from 192.168.10.20: Unauthorized: The request you have made requires authentication.
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值