Asp.net SSRS Web服务访问异常-401未经授权方案';Ntlm&x27;

Asp.net SSRS Web服务访问异常-401未经授权方案';Ntlm&x27;,asp.net,reporting-services,ssrs-2008,Asp.net,Reporting Services,Ssrs 2008,我已经为下面的.NETFramework4.0异常花费了一天的时间。我在网上研究过解决方案,但还没有找到一个可行的。 请提前帮助和感谢 我的asp.net web应用程序在本地PC环境中运行正常,该环境同时具有IIS 8.0和本地SQL Server 2012实例,但 当我将其部署到同时具有IIS 8.0和SQL server 2012实例的web服务器时,异常会出现 例外情况: Stack Trace: [WebException: The remote server returned a

我已经为下面的.NETFramework4.0异常花费了一天的时间。我在网上研究过解决方案,但还没有找到一个可行的。 请提前帮助和感谢

我的asp.net web应用程序在本地PC环境中运行正常,该环境同时具有IIS 8.0和本地SQL Server 2012实例,但 当我将其部署到同时具有IIS 8.0和SQL server 2012实例的web服务器时,异常会出现

例外情况:

Stack Trace: 

[WebException: The remote server returned an error: (401) Unauthorized.]
   System.Net.HttpWebRequest.GetResponse() +8527180
   System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +237

[MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +14539490
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +622
   MyAspNetSolution.Services.ReportService2010.ReportingService2010Soap.ListChildren(ListChildrenRequest request) +0
   MyAspNetSolution.Services.ReportService2010.ReportingService2010SoapClient.MyAspNetSolution.Services.ReportService2010.ReportingService2010Soap.ListChildren(ListChildrenRequest request) +102
   MyAspNetSolution.Services.ReportService2010.ReportingService2010SoapClient.ListChildren(TrustedUserHeader TrustedUserHeader, String ItemPath, Boolean Recursive, CatalogItem[]& CatalogItems) +220
   MyAspNetSolution.Services.ReportServerInfoService.ListReportCollection(String itemPath, Boolean recursive) +653
   MyAspNetSolution.AspxPageListAllReportsOnSSRS.Page_Load(Object sender, EventArgs e) +151
   ....  
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034
详情/我的故事:

我有一个asp.net web表单应用程序,该应用程序具有对SQL Server 2012 Reporting service的SOAP web服务的web引用并使用该服务(请参阅)。 我的名为“MyAspNetSolution”的asp.net web表单解决方案是使用VS 2012/.net framework 4.5和本地企业版SQL Server 2012开发的。该解决方案包含一个web表单应用程序项目 ,以及其他自定义类库项目。其中一个类库项目是名为“MyAspNetSolution.Services”的类库项目,它具有对的web引用 并使用SSRS SOAP web服务,如:

...
using MyAspNetSolution.Services.ReportService2010;
using System.Net;
...

namespace MyAspNetSolution.Services
{
    public class ReportServerInfoService
    {
            public CatalogItem[] ListReportCollection(string itemPath, bool recursive)
            {
            CatalogItem[] reportCollection = {};

            try
            {
                ReportService2010.ReportingService2010SoapClient client = new ReportService2010.ReportingService2010SoapClient();
                client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

                client.Open();
                TrustedUserHeader t = new TrustedUserHeader();

                try
                {
                    // I need to list of children of a specified folder.
                    client.ListChildren(t, itemPath, recursive, out reportCollection); // see http://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.listchildren.aspx
                }
                catch (SoapException ex)
                {
                    _logger.Error("ReportServerManagementService--" + ex);
                }
            }
            catch (SoapException ex)
            {
                _logger.Error("ReportServerManagementService--" + ex);
            }

            return reportCollection;
           }
    }
}
在我的web应用程序项目web.config中,SQL Server 2012 Reporting service的SOAP web服务的端点、绑定和其他部分如下所示:

...
 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="ReportingService2010Soap">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm"></transport>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://my-pc-network-domain-or-server-domain/ReportServer_SQL2012/ReportService2010.asmx" binding="basicHttpBinding" bindingConfiguration="ReportingService2010Soap" contract="ReportService2010.ReportingService2010Soap" name="ReportingService2010Soap"/>
    </client>
  </system.serviceModel>
...  
。。。
...  
p/S:

我还研究了以下线程(用于SharePoint客户端开发),代码与我正在开发的(用于SSRS客户端开发)相同,但在我的本地PC环境中工作,而不是在web服务器上

或其他资源:


您应该尝试NetworkCredentials并将其传递给客户端。如果仍然出现错误,请将其放在wcf配置文件中:

<identity>
    <servicePrincipalName value=""/>
</identity>

谢谢

将此添加为endpoint元素的子元素为我解决了错误。非常感谢。