错误调用Web服务401:未经授权 [英] Error calling web service 401: Unauthorized

查看:1154
本文介绍了错误调用Web服务401:未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到

  

请求失败,HTTP状态401:未经授权

我的Web服务是IIS6 .NE​​T 4的运行。我的客户是.NET 2 IIS6运行

当我运行客户端和serivce我的本地主机上它的工作原理。 当我移动服务,Web服务器,我得到上述错误。我已经设置允许

我已经试过了匿名访问和放大器每个组合;在IIS中集成的Windows身份验证 我可以通过布劳尔访问Web服务,并使用Web服务工作室称呼它好了,它只是不,当我从其他.NET服务调用工作

更新

我已经检查了IUSR帐户具有NTFS文件权​​限,并且还增加了在当地的安全政策,可以访问服务器通过网络中的用户。

当我从WebService的工作室把它提出了两个要求先叫回来401,然后,它调用再次传递'授权'和作品。见下文。因此,出于某种原因,我的匿名访问不工作。正如当我只有匿名访问选中,并集成Windows身份验证从取消选中的布劳尔我甚至不能访问它。

 内容类型:text / xml的;字符集= UTF-8
SOAPAction报:http://tempuri.org/HelloWorld
主持人:webdev1
内容长度:314
期望:100-继续
连接:保持活动

?&LT; XML版本=1.0编码=UTF-8&GT;&LT;肥皂:信封XMLNS:肥皂=htt​​p://schemas.xmlsoap.org/soap/envelope/的xmlns:XSI =HTTP ://www.w3.org/2001/XMLSchema-instance的xmlns:XSD =http://www.w3.org/2001/XMLSchema&GT;&LT;肥皂:身体与GT;&LT;的HelloWorld xmlns="http://tempuri.org/"><echo>sd</echo></HelloWorld></soap:Body></soap:Envelope>

HTTP / 1.1 401未经授权
内容长度:1539
内容类型:text / html的
服务器:Microsoft-IIS / 6.0
WWW身份验证:协商
WWW身份验证:NTLM
日期:星期四,2012 12时26分33秒格林尼治标准​​时间6月28日
代理服务器的支持:基于会话的认证功能
 

呼叫2(自动发生)

  POST HTTP://webdev1/CSHRService/CSHR.asmx HTTP / 1.1
内容类型:text / xml的;字符集= UTF-8
SOAPAction报:http://tempuri.org/HelloWorld
授权:协商YIILzQYGKwYBBQUCoIILwTCCC72gJDAiB / EG1WyqaLj3E67GA0 ......
主持人:webdev1
内容长度:314
期望:100-继续

?&LT; XML版本=1.0编码=UTF-8&GT;&LT;肥皂:信封XMLNS:肥皂=htt​​p://schemas.xmlsoap.org/soap/envelope/的xmlns:XSI =HTTP ://www.w3.org/2001/XMLSchema-instance的xmlns:XSD =http://www.w3.org/2001/XMLSchema&GT;&LT;肥皂:身体与GT;&LT;的HelloWorld xmlns="http://tempuri.org/"><echo>sd</echo></HelloWorld></soap:Body></soap:Envelope>
HTTP / 1.1 200 OK
日期:星期四,2012 12点26分34秒格林尼治标准​​时间6月28日
服务器:Microsoft-IIS / 6.0
WWW身份验证:协商oYGgMIGdoAMKAQChCwYJKoZIgvcSAQICooGIBI ..
的X ASPNET-版本:4.0.30319
缓存控制:私人,最大年龄= 0
内容类型:text / xml的;字符集= UTF-8
内容长度:360
 

我的code调用该服务只是

  CSHRService cshrService =新CSHRService();
  字符串s = cshrService.HelloWorld(D);
 

解决方案

我的问题是IUSR帐户的密码是错的我刚刚改了密码或创建一个新帐户来运行应用程序池,并将其固定它。

I get

The request failed with HTTP status 401: Unauthorized

My web service is .NET 4 running on IIS6. My client is .NET 2 running on IIS6

When I run the both client and serivce on my local host it works. When I move the service to the web server I get the above error. I have set Allow An

I have tried every combination of anonymous access & integrated Windows authentication within IIS I can access the web service via a brower and call it using Web Service Studio ok, it just does not work when I call from another .NET service

UPDATE

I have checked that the IUSR account has NTFS file permissions and is also added in local security policy as a USER that can access the server over network.

When I call from WebService Studio it makes two request first called gets back 401, then it calls again passing 'Authorization' and works. See below. So for some reason my anonymous access is not working. As when I only have anonymous access ticked and integrated Windows authentication unticked I cannot even access it from the brower

Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/HelloWorld"
Host: webdev1
Content-Length: 314
Expect: 100-continue
Connection: Keep-Alive

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><HelloWorld xmlns="http://tempuri.org/"><echo>sd</echo></HelloWorld></soap:Body></soap:Envelope>

HTTP/1.1 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
Date: Thu, 28 Jun 2012 12:26:33 GMT
Proxy-Support: Session-Based-Authentication

Call 2 (happens automatically)

POST http://webdev1/CSHRService/CSHR.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/HelloWorld"
Authorization: Negotiate YIILzQYGKwYBBQUCoIILwTCCC72gJDAiB/EG1WyqaLj3E67GA0......
Host: webdev1
Content-Length: 314
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><HelloWorld xmlns="http://tempuri.org/"><echo>sd</echo></HelloWorld></soap:Body></soap:Envelope>
HTTP/1.1 200 OK
Date: Thu, 28 Jun 2012 12:26:34 GMT
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate oYGgMIGdoAMKAQChCwYJKoZIgvcSAQICooGIBI..
X-AspNet-Version: 4.0.30319
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 360

My code that calls the service is just

  CSHRService cshrService = new CSHRService();
  string s = cshrService.HelloWorld("d");

解决方案

My problem was the IUSR account password was wrong I just changed the password or create a new account to run the app pool as and it fixed it.

这篇关于错误调用Web服务401:未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆