SoapHttpClientProtocol.ReadResponse - HTTP状态401失

2019-07-30 03:47发布

我有一个使用到SQL Server Reporting Services的208 R2实例的引用(使用ReportService2010.asmx服务端点)的ASP.NET(V2.0)的Web应用程序。 Web应用程序托管在服务器A和Reporting Services实例托管ServerB上。 ServerA上运行Windows Server 2003(IIS6)和ServerB正在运行Windows Server 2008 R2。

Web应用程序配置为使用Windows身份验证和模拟接通。 当我在ServerA上本地运行的Web应用程序(使用远程桌面连接)它的工作原理,但是当我从我的桌面机(Windows XP中)我得到以下错误运行:

在“/ MyWebApp应用程序的服务器错误。

请求失败,HTTP状态401:未经授权。 说明:在当前Web请求的执行过程中发生未处理的异常。 请检查堆栈跟踪有关该错误它起源于代码的详细信息和。

异常详细信息:System.Net.WebException:HTTP状态401失败的请求:未经授权。

源错误:

在当前web请求的执行过程中生成未处理的异常。 有关异常原因和发生位置的信息可以使用异常堆栈跟踪下面来识别。

堆栈跟踪:

[引发WebException:请求失败,HTTP状态401:未授权] System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage消息,WebResponse的响应,流responseStream,布尔asyncCall)431289
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串方法名,对象[]参数)204
ReportingServices.ReportingService2010.ListChildren(字符串ItemPath,布尔递归)+81 Default.LoadReports()+54
Default.Page_Load(对象发件人,EventArgs的)224
错误帮助(IntPtr的FP,对象O,对象吨,EventArgs的)14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发件人,EventArgs的)35 System.Web.UI.Control.OnLoad(EventArgs的)99
System.Web.UI.Control.LoadRecursive()+50
System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)627


版本信息:Microsoft .NET Framework版本:2.0.50727.3634; ASP.NET版本:2.0.50727.3634

LoadReports方法:

private void LoadReports()
{
    ReportingService2010 rService = new ReportingService2010();

    rService.Credentials = System.Net.CredentialCache.DefaultCredentials;
    CatalogItem[] catalogItems;
    catalogItems = rService.ListChildren(ReportPath, true);

    BuildTree(catalogItems);
}

ServerA上的应用程序事件日志包含以下的其他详细信息:

Event Type: Warning
Event Source:   ASP.NET 2.0.50727.0
Event Category: Web Event 
Event ID:   1309
Date:       28/06/2012
Time:       11:25:16
User:       N/A
Computer:   ServerA
Description:
Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 28/06/2012 11:25:16 
Event time (UTC): 28/06/2012 10:25:16 
Event ID: 11f6bec3e91045229f4e34a5d2de78e9 
Event sequence: 4 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/Root/MyWebApp-1-129853527126453497 
    Trust level: Full 
    Application Virtual Path: /MyWebApp 
    Application Path: c:\inetpub\wwwroot\MyWebApp\ 
    Machine name: ServerA 

Process information: 
    Process ID: 1180 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: WebException 
    Exception message: The request failed with HTTP status 401: Unauthorized. 

Request information: 
    Request URL: http://ServerA/MyWebApp/Default.aspx 
    Request path: /MyWebApp/Default.aspx 
    User host address: 192.168.100.130 
    User: DOMAIN\mylogin 
    Is authenticated: True 
    Authentication Type: Negotiate 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 1 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    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 ReportingServices.ReportingService2010.ListChildren(String ItemPath, Boolean Recursive)
   at Default.LoadReports()
   at Default.Page_Load(Object sender, EventArgs e)
   at System.Web.Util.CalliHe.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Answer 1:

启用身份验证委派

使用Active Directory用户和计算机Microsoft管理控制台(开始>运行>“DSA.MSC”)中,打开服务器A服务器条目的属性。 在委派,选择信任此计算机来委派任何服务(仅Kerberos的)。

配置的SPN

使用下面的命令来注册服务主体名称(SPN):

setspn -S http/ServerB ReportingServicesServiceAccount
setspn -S http/ServerB.domain.com ReportingServicesServiceAccount

ReportingServicesServiceAccount是用来运行ServerB上Reporting Services服务的服务帐户。



文章来源: SoapHttpClientProtocol.ReadResponse - The request failed with HTTP status 401: Unauthorized