Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Reporting Services Web Services with .NET CORE 2

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 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:ProjectsRSWcfRSWcf.sln"

9. To Run the Application after publishing, execute this command:

dotnet "C:ProjectsRSWcfRSWcfbinDebugnetcoreapp2.0RSWcf.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

Share the post

Reporting Services Web Services with .NET CORE 2

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×