简体   繁体   English

SSRS Web服务访问异常 - 401未授权方案'Ntlm'

[英]SSRS Web Service access exception - 401 Unauthorized scheme 'Ntlm'

I already spent a work day long for the following .NET framework 4.0 exception. 我已经花了一天的工作时间来处理以下.NET framework 4.0异常。 I have researched solutions online, but I haven't found out a working one. 我已经在线研究过解决方案,但我还没有找到合适的解决方案。 Please help and thanks in advance. 请提前帮助和感谢。

My asp.net web application runs OK on my local PC environment that has both IIS 8.0 and local SQL Server 2012 instance, but the exception rises when I deployed it to the web server that has both IIS 8.0 and SQL Server 2012 instance. 我的asp.net Web应用程序具有IIS 8.0和本地SQL Server 2012实例的本地PC环境运行正常, 但当我将其部署到同时具有IIS 8.0和SQL Server 2012实例的Web服务器时异常上升。

The excetpion: 除外:

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

Details/My story: 细节/我的故事:

I have an asp.net web form application that has a web reference to and consumes the SOAP web service of SQL Server 2012 Reporting Service (see http://msdn.microsoft.com/en-us/library/ee640743.aspx ). 我有一个asp.net Web表单应用程序,它具有Web引用并使用SQL Server 2012 Reporting Service的SOAP Web服务(请参阅http://msdn.microsoft.com/en-us/library/ee640743.aspx )。 My asp.net web form solution named "MyAspNetSolution" is developed with VS 2012 / .NET framework 4.5, and a local enterprise-edition SQL Server 2012. The solution contains a web form application project , and other custom class library projects. 我的asp.net Web表单解决方案名为“MyAspNetSolution”,是使用VS 2012 / .NET framework 4.5和本地企业版SQL Server 2012开发的。该解决方案包含一个Web表单应用程序项目和其他自定义类库项目。 One of those class library projects is a class library project named "MyAspNetSolution.Services" that has web reference to and consumes the SSRS SOAP web service like: 其中一个类库项目是名为“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;
           }
    }
}

And the section for the end point, bindings and othes of the SOAP web service of SQL Server 2012 Reporting Service in my web application project Web.config looks like: 在我的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: P / S:

I also looked at the following thread (for SharePoint client development), the codes are the same as what I am developing (for SSRS client development) but working on my local PC environment, but not on the web server. 我还查看了以下线程(对于SharePoint客户端开发),代码与我正在开发的代码(用于SSRS客户端开发)相同,但是在我的本地PC环境中工作,但不在Web服务器上。

Sharepoint web services -- The HTTP request is unauthorized with client authentication scheme 'Ntlm'. Sharepoint Web服务 - HTTP请求未经授权使用客户端身份验证方案'Ntlm'。 The authentication header received from the server was 'NTLM' 从服务器收到的身份验证标头是'NTLM'

or another resource: 或其他资源:

http://jaliyaudagedara.blogspot.com/2012/05/accessing-report-server-using-report.html http://jaliyaudagedara.blogspot.com/2012/05/accessing-report-server-using-report.html

You should try NetworkCredentials and pass them to the client. 您应该尝试使用NetworkCredentials并将它们传递给客户端。 If you still get error then place this in your wcf config file : 如果仍然出现错误,请将其放在wcf配置文件中:

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

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MS Exchange Web服务API和401未经授权的异常 - MS Exchange Web Service API and 401 unauthorized exception SSRS Reportviewer-401未经授权 - SSRS Reportviewer - 401 Unauthorized 如何在 Sharepoint 中引发 401(未经授权的访问)异常? - How to raise a 401 (Unauthorized access) exception in Sharepoint? SSRS 2008 R2升级-Web服务访问问题-未经授权的401 - SSRS 2008 R2 upgrade - webservice access issue - 401 unauthorized 调用远程Web服务-“请求失败,HTTP状态为401:未经授权” - Calling Remote Web Service — “The request failed with HTTP status 401: Unauthorized” Web服务失败,请求失败,HTTP状态为401:未经授权 - Web service failing with The request failed with HTTP status 401: Unauthorized Web服务在一台服务器上失败(401未经授权),但在另一台服务器上未失败 - Web service fails (401 Unauthorized) on one server but not on the other WCF Web服务WebInvoke操作返回401未经授权 - WCF Web Service WebInvoke Operation Returns 401 Unauthorized 接收到SSRS 2008的HttpWebRequest中的“未经授权(401)”错误 - Receiving “Unauthorized (401)” error in HttpWebRequest to SSRS 2008 请求失败,HTTP状态为401未经授权的ssrs - the request failed with http status 401 unauthorized ssrs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM