Blog Post

SQL Server Support Blog
2 MIN READ

Reporting Services Web Services with .NET CORE 2

Krishnakumar_Rukmangathan's avatar
Jan 16, 2019
First published on MSDN on Sep 19, 2017


Any application built using .NET CORE SDK can be executed on any platform (Windows, Linux & Mac). But due to this there are a lot of APIs available in .NET Framework that are no longer available in .NET CORE. One of the missing APIs is Web Service (SOAP) Clients. The way to move forward is to use WCF Connected Services and create a BasicHttpBinding against Reporting Services Web Services.



In this blog, we will look at accessing the SSRS Web Services using .NET CORE and WCF Connected Services.

Reporting Services (ReportService2010.asmx):

1. Create a New Project - .NET Core (Console App)





2. To add a Connected Service Reference, the Extension needs to be added to Visual Studio. This isn’t install by Default.

  • Open Tools -> Extension and Updates

  • Search for “Microsoft WCF Web Service Reference Provider”

  • Download and Install – “Microsoft WCF Web Service Reference Provider”

  • Restart Visual Studio and Reopen the Project


3. Add a Connected Service and Choose “Microsoft WCF Web Service Reference Provider - Preview” :







4. Provide the Reporting Services Web Service URL: http://servername/Reportserver/ReportService2010.asmx





5. Enter the Namespace and click Finish

6. Update Program.cs with the following Code:
using System;
using System.ServiceModel;
using System.Threading.Tasks;
using RSService;

namespace RSWcf
{
class Program
{
static ReportingService2010SoapClient rsclient = null;

static void Main(string[] args)
{
BasicHttpBinding rsBinding = new BasicHttpBinding();
rsBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
rsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

EndpointAddress rsEndpointAddress = new EndpointAddress("http://servername/Reportserver/ReportService2010.asmx");

rsclient = new ReportingService2010SoapClient(rsBinding, rsEndpointAddress);

var output = rsListChildren("/");
output.Wait();

if(output.Status == TaskStatus.RanToCompletion && output.Result.Length > 0)
{
foreach(CatalogItem item in output.Result)
{
Console.WriteLine(String.Format("Item Path: {0}", item.Path));
}
}

Console.WriteLine("Completed!");
Console.ReadLine();
}

private static async Task<CatalogItem[]> rsListChildren(String ItemPath)
{
TrustedUserHeader trustedUserHeader = new TrustedUserHeader();
ListChildrenResponse listChildrenResponse = null;
try
{
listChildrenResponse = await rsclient.ListChildrenAsync(trustedUserHeader, ItemPath, false);
}
catch(Exception exception)
{
Console.WriteLine(exception.Message + exception.StackTrace);
return new CatalogItem[0];
}
return listChildrenResponse.CatalogItems;
}
}
}


7. Execute the Project, you would see an output like this:





8. To Publish the Project for all operating systems, execute this command:
dotnet publish "C:\Projects\RSWcf\RSWcf.sln"


9. To Run the Application after publishing, execute this command:
dotnet "C:\Projects\RSWcf\RSWcf\bin\Debug\netcoreapp2.0\RSWcf.dll"




Author: Kane Conway – Support Escalation Engineer, SQL Server BI Developer team, Microsoft

Reviewer: Krishnakumar Rukmangathan – Support Escalation Engineer, SQL Server BI Developer team, Microsoft
Updated Jan 16, 2019
Version 2.0

5 Comments

  • agerard's avatar
    agerard
    Copper Contributor

    Is there any info or documentation on how to add the SSRS 2017 API as a connected service in a .NET 5 or 6 application?

  • lnoguera's avatar
    lnoguera
    Copper Contributor

    Hi, I have been able to render reports from our report server in .net core 3.1 by following this tutorial. https://alanjuden.com/2016/11/10/mvc-net-core-report-viewer/

  • LouAnn2020's avatar
    LouAnn2020
    Copper Contributor

    Does anyone have an example of rendering a report in .net core?

  • melchor's avatar
    melchor
    Copper Contributor

    Hi, I am able to implement above code but do you have sample implementation to render SSRS in .net core web application. I don't want to use third party reporting tool. Thank you.

  • Andrew51's avatar
    Andrew51
    Copper Contributor

    When I call:-

    listChildrenResponse = await rsclient.ListChildrenAsync(trustedUserHeader, ItemPath, false);

     

    I get:-

    'The provided URI scheme 'http' is invalid; expected 'https'.

     

    But you're using http so am I.  Strange.