Friday, December 19, 2014

Session 13: Using SSRS Web Services
AnandFriday, December 19, 2014 0 comments


                      Session 13: Using SSRS Web Services

SSRS exposes all functionality of reporting services through Web service.
Its bascially a XML web service and has a SOAP API.
It provides 2 endpoints:
1. Report execution
2. Report Management

Mainly there are 2 ways to use the SSRS web services:
1. Using Microsoft.NET Framework
2. Using RS.exe

Lets look at an example to use SSRS web services using Microsoft C#.

Step 1:
Create a Visual studio 2010 console application (you can use any Visual Studio version)
I am calling the application MyFirstSSRSWebService.

Step 2:
Next click add service reference:

Step 3:
Click advanced--> add web reference -- url - http://localhost/reportserver/reportservice2005.asmx
(replace localhost with your report server name).
Then click add reference


Step 4:
You should be seeing the SSRS webservice that you just added, in the solution explorer:


Step 5 :
I have created a report called MyFirstReport in my local, and given it a small description.


Step 6:
Now lets try to programmatically display this report name and the description

Copy paste the following c# code:


using System;
using MyFirstSSRSWebService.myPC;

namespace MyFirstSSRSWebService
{
    class Program
    {
        static void Main(string[] args)
        {
            ReportingService2005 rs = new ReportingService2005();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rs.Url = "http://localhost/reportserver_SSRSexpress/reportservice2005.asmx";

            Property name = new Property();
            name.Name = "Name";

            Property description = new Property();
            description.Name = "Description";

            Property[] properties = new Property[2];
            properties[0] = name;
            properties[1] = description;

            try
            {
                Property[] returnProperties = rs.GetProperties(
                "/HelloWorld/MyFirstReport", properties);

                foreach (Property p in returnProperties)
                {
                    Console.WriteLine(p.Name + ": " + p.Value);
                }
                Console.ReadKey();
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
            }
        }
    }
}



Step 7: Run the code, you should be seeing the following output


Likewise, I would encourage you to explore other methods of this web service as well.
One common activity people do, is to programmatically render a report in excel/pdf etc
In Category :
About The Author Anand Anand is a Microsoft Certified MCITP (Business Intelligence Infrastructure Using Microsoft SQL Server 2008), MCTS (SQL Server 2008, Business Intelligence Development and Maintenance) with 8 + years of experience in the Finance , Education, Healthcare, Banking and Insurance, Telecom domain focused on delivering software design, development, and data migrations from diversified data sources using Business Intelligence analysis tools..

0 comments

Post a Comment