是什么原因导致" HTTP状态401:确定] [英] What causes "HTTP status 401: OK"

查看:1043
本文介绍了是什么原因导致" HTTP状态401:确定]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET Web服务,当我偶尔把它返回正确的响应,其他时候它返回异常请求失败,HTTP状态401:确定可有人请我提供一些原因,这会发生?正如我似乎无法找到HTTP 401任何事情,确定的消息,因为200是OK和401的未经授权的...为什么我的Web服务托管在IIS6是返回此?

I have an ASP.NET Web Service, when I call it occasionally it returns the correct response, other times it is returning the exception The request failed with HTTP status 401: OK. Can someone please provide me with some reasons why this would be occurring? As I can't seem to find anything on HTTP 401 and a message of OK since 200 is OK and 401 is Unauthorized... Why would my Web Service hosted in IIS6 be returning this?

下面是直接异常详细信息:

Here's the direct exception details:

Message:
    The request failed with HTTP status 401: OK.
Stack Trace:
    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
    at ws.Main.MethodName(param1, param2)

我会试图让Wireshark的数据包跟踪这个错误,当我提供了吧。

I will be trying to get a WireShark packet trace for this error when I am provided with it.

客户端和Web服务是code,我们维持。唯一的例外只发生间歇性和不总是通过凭证详细信息有效的AD用户的详细信息的帐户和IIS站点正在使用Windows身份验证。

Both the client and the Web Service are code that we maintain. The exception only occurs intermittently and not always, the credential details passed through are valid AD user details for an account and IIS site is using Windows Authentication.

推荐答案

我已经找到了原因,并有一个答案。

I have found the cause and have an answer.

的问题是由在同一时间在相同的TCP管访问WebService的多个线程引起的。这导致IIS重置身份验证握手,结果收到申请的HTTP 401未授权例外代替 200 OK 消息,.NET是报告的反应是HTTP 401 OK ,但是使用Wireshark的我能够确定的内容仍然是HTTP 401未授权

The problem was caused by multiple threads accessing the WebService at the same time over the same TCP pipe. This caused IIS to reset the authentication handshake and as a result the application received HTTP 401 UNAUTHORIZED exceptions in place of the 200 OK message, .NET was reporting the response was HTTP 401 OK, however using WireShark I was able to determine that the content was still HTTP 401 UNAUTHORIZED.

由于问题的多线程的性质,我们有它发生的非常间歇性。

Due to the multi-threaded nature of the problem we had it occur very intermittently.

解决方案是编写包含我们的自动生成的WS代理类(从WSDL)一个新的代理类,而这个新的代理类中实现了每一个方法的SYNCLOCK对象。

Solution was to write a new proxy class that encompass our auto-generated ws proxy class (from the WSDL) and implementing a SYNCLOCK object over every method within this new proxy class.

这个问题似乎也消失时,我用的是服务器的名称,而不是DNS名称,因为每个单独的线程中调用去了一个不同的TCP管道。

The problem also seemed to go away when I was using the server name rather than a DNS name because each separate thread call went on a different TCP pipe.

这篇关于是什么原因导致" HTTP状态401:确定]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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