SoapHttpClientProtocol.ReadResponse - A solicitação falhou com o status HTTP 401: Não autorizado
Eu tenho um aplicativo da Web ASP.NET (v2.0) que usa uma referência a uma instância do SQL Server Reporting Services 208 R2 (usando o ponto de extremidade de serviço ReportService2010.asmx). O aplicativo da Web está hospedado no ServerA e a instância do Reporting Services está hospedada no ServerB. O ServerA está executando o Windows Server 2003 (IIS6) e o ServerB está executando o Windows Server 2008 R2.
O aplicativo da Web está configurado para usar a Autenticação do Windows e a representação está ativada. Quando executo o aplicativo da Web localmente no ServerA (usando uma conexão de área de trabalho remota) ele funciona, mas quando eu corro da minha máquina de desktop (Windows XP) recebo o seguinte erro:
Erro do servidor no aplicativo '/ MyWebApp'.A solicitação falhou com o status HTTP 401: Não autorizado. Descrição: ocorreu uma exceção não tratada durante a execução da solicitação da web atual. Revise o rastreamento de pilha para obter mais informações sobre o erro e onde ele foi originado no código.
Detalhes da exceção: System.Net.WebException: A solicitação falhou com o status HTTP 401: não autorizado.
Erro de origem:
Uma exceção não tratada foi gerada durante a execução da solicitação da web atual. Informações sobre a origem e a localização da exceção podem ser identificadas usando o rastreamento de pilha de exceção abaixo.
Rastreamento de pilha:
[WebException: A solicitação falhou com o status HTTP 401: Não autorizado.] System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse (mensagem SoapClientMessage, resposta WebResponse, Stream responseStream, Boolean asyncCall) +431289
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (String methodName, Object [] parameters) +204
ReportingServices.ReportingService2010.ListChildren (String ItemPath, Booleano Recursivo) +81 Padrão.LoadReports () +54
Default.Page_Load (remetente do objeto, EventArgs e) +224
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Objeto o, Objeto t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback (Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad (EventArgs e) +99
System.Web.UI.Control.LoadRecursive () +50
System.Web.UI.Page.ProcessRequestMain (booleano includeStagesBeforeAsyncPoint, booleano includeStagesAfterAsyncPoint) +627
Informações sobre versão: Microsoft .NET Framework Versão: 2.0.50727.3634; Versão do ASP.NET: 2.0.50727.3634
Método de LoadReports:
private void LoadReports()
{
ReportingService2010 rService = new ReportingService2010();
rService.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] catalogItems;
catalogItems = rService.ListChildren(ReportPath, true);
BuildTree(catalogItems);
}
O log de eventos do aplicativo no ServerA contém os seguintes detalhes adicionais:
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)