June 2007 Entries
Example of using SSRS SOAP API

This example uses adventure works sample  database and reports, please refer to books on line for setup instructions.

1.       Open Visual Studio and create a console application (VB or C#)

2.       Replace the code in Module.vb or Module.cs with the appropriate code snippet

a.       C#

using System;

using SoapAPI.ReportService2005;

 

class Module1

{

 

         public void Main()

         {

                 ReportingService2005 rs = new ReportingService2005();

                 rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

 

                 rs.Url = "http://Localhost/reportserver/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("/AdventureWorks Sample Reports/Company Sales", properties);

                          Property p;

                          foreach ( p in returnProperties) {

                                   Console.WriteLine((p.Name + ": " + p.Value));

                          }

                 }

 

                 catch (Exception e) {

                          Console.WriteLine(e.Message);

                 }

                 finally {

                          Console.ReadLine();

                 }

         }

 

}

b.      VB

Imports System

Imports SoapAPI.ReportService2005

 

Module Module1

 

    Sub Main()

        Dim rs As New ReportingService2005

        rs.Credentials = System.Net.CredentialCache.DefaultCredentials

 

        rs.Url = "http://Localhost/reportserver/reportservice2005.asmx"

 

        Dim name As New [Property]

        name.Name = "Name"

 

        Dim description As New [Property]

        description.Name = "Description"

 

        Dim properties(1) As [Property]

        properties(0) = name

        properties(1) = description

        Try

            Dim returnProperties As [Property]() = rs.GetProperties("/AdventureWorks Sample Reports/Company Sales", properties)

            Dim p As [Property]

            For Each p In returnProperties

                Console.WriteLine((p.Name + ": " + p.Value))

            Next p

 

        Catch e As Exception

            Console.WriteLine(e.Message)

        Finally

            Console.ReadLine()

        End Try

    End Sub

 

End Module

3.       Run the application

Example of using SSRS SOAP API

This example uses adventure works sample  database and reports, please refer to books on line for setup instructions.

1.       Open Visual Studio and create a console application (VB or C#)

2.       Replace the code in Module.vb or Module.cs with the appropriate code snippet

a.       C#

using System;

using SoapAPI.ReportService2005;

 

class Module1

{

 

         public void Main()

         {

                 ReportingService2005 rs = new ReportingService2005();

                 rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

 

                 rs.Url = "http://Localhost/reportserver/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("/AdventureWorks Sample Reports/Company Sales", properties);

                          Property p;

                          foreach ( p in returnProperties) {

                                   Console.WriteLine((p.Name + ": " + p.Value));

                          }

                 }

 

                 catch (Exception e) {

                          Console.WriteLine(e.Message);

                 }

                 finally {

                          Console.ReadLine();

                 }

         }

 

}

b.      VB

Imports System

Imports SoapAPI.ReportService2005

 

Module Module1

 

    Sub Main()

        Dim rs As New ReportingService2005

        rs.Credentials = System.Net.CredentialCache.DefaultCredentials

 

        rs.Url = "http://Localhost/reportserver/reportservice2005.asmx"

 

        Dim name As New [Property]

        name.Name = "Name"

 

        Dim description As New [Property]

        description.Name = "Description"

 

        Dim properties(1) As [Property]

        properties(0) = name

        properties(1) = description

        Try

            Dim returnProperties As [Property]() = rs.GetProperties("/AdventureWorks Sample Reports/Company Sales", properties)

            Dim p As [Property]

            For Each p In returnProperties

                Console.WriteLine((p.Name + ": " + p.Value))

            Next p

 

        Catch e As Exception

            Console.WriteLine(e.Message)

        Finally

            Console.ReadLine()

        End Try

    End Sub

 

End Module

3.       Run the application

How to run a subscription on demand by Trigerring Events in SSRS from command line

One of my custmers wanted to use their own scheduler control all of their SSRS subscriptions. if you need to do the same here is the step by step example of acomplishing this task.

Create either a datadriven or regular subscription

1.       In Management studio connect to the Database Engine (local)

2.       Expand the database and drill down to Report Server Database

3.       Click on File à New à query with current connection

4.       In the query window type the following command and execute it to get the subscription ID

Select *  From subscriptions

 

5.       To locate the correct subscription look  at  description column

6.       Open  Note pad and  copy and paste the following code snippet

Sub Main()

    Try

        rs.FireEvent("TimedSubscription", "{SubscriptionID}")

            Catch ex As Exception

        Console.WriteLine(ex.Message)

   End Try

End Sub

7.       Replace {SubscriptionID}  with the actual SubscriptionID from the query executed in step 4

8.        Save this file as c:\ExecuteSubscription.rss

9.       Open a command window

a.       Click on Start à run

b.      Type in Cmd.exe and press enter

10.   In the command window execute the following command

rs.exe -i c:\ExecuteSubscription.rss -s http://localhost/reportserver

11.   You should get the following error

rs.exe -i c:\ExecuteSubscription.rss -s http://localhost/reportserverSystem.Web.Services.Protocols.SoapException: The permissions granted to user ‘{YourUserName}’ are insufficient for performing this operation

12.   By default no users or Roles are allowed to  Generate Events .

13.   Open Report Manager click on Site Settings then click on Site settings Security.

14.   Press Edit next to Generate events

15.   Then Click on System Administrator.

16.   Check the Generate events task.

17.   Re-execute the command in step 9.

18.   View the file share and make sure all the files were created successfully.