This post has been republished via RSS; it originally appeared at: SQL Server Support articles.
First published on MSDN on Sep 19, 2017Any 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