3

I already spent a work day long for the following .NET framework 4.0 exception. 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.

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). 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. 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:

...
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:

...
 <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:

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 web services -- The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'

or another resource:

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

1 Answer 1

1

You should try NetworkCredentials and pass them to the client. If you still get error then place this in your wcf config file :

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

Thanks

1
  • Adding this identity element as a child of the endpoint element resolved the error for me. Thank you
    – mcdon
    May 1, 2018 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.