3

In my project I have a web reference to SSRS (2005). I would like to display links that can take users directly to rendered reports. I know I can provide a link such as this one:

http://server/ReportServer/Pages/ReportViewer.aspx?/path/to/report&rs:Command=Render&rc:parameters=false&rs:format=HTML4.0

The question is how can I get that URL from the web service? And if the report takes parameters is there a way to provide values to the web service and have it format the URL for me?

I know I can build the URL myself, but I don't like reinventing wheels.

JC Ford
  • 6,946
  • 3
  • 25
  • 34

2 Answers2

7

There are a few things to think of about HOW SSRS works and HOW MUCH TIME you want to invest in monkeying with it.

I. You can traverse the root but I highly doubt you meant that. From the root you can add items whether they are directories or reports. And to add to that you can add the parameter directly to the Rest URI to render a report and you may also output a value as well. For example:

Main part of address root:

http:// <server>/ReportServer/Pages/ReportViewer.aspx?

path to directory:

%2fTest

path to report (labeled it the same name lol)

%2fTest

what to do with it? (render it)

&rs:Command=Render

Put a paremeter in and execute it as well (Yes I called my parameter Test too!)

&Test=Value

Put it all together:

http:// <servername>/ReportServer/Pages/ReportViewer.aspx?%2fTest%2fTest&rs:Command=Render&Test=Value

II. You have a database you can query for traversing things but I believe MS does NOT document it well. Generally it is a SQL Server database named 'ReportServer' on whatever server you installed SSRS on. Generally most items are in the table 'dbo.Catalog' with 'Type' of 2 for reports. You can get their info and even parameters from them there.

III. You want to go full bore and dive into .NET and just talk to the service directly? You can do that too. You need the two main services though to do that:

 A: http://<Server Name>/reportserver/reportservice2010 (gets info on existing items on server)

 B: http:// <Server Name>reportserver/reportexecution2005 (gets info for in code creating reports to types directly in code)

I had another thread on exporting this here: Programmatically Export SSRS report from sharepoint using ReportService2010.asmx; but you will to get info as well probably. ONCE you have created the proxy classes (or made a reference to the web services) you can do code in .NET like so. These services do all the magic so without them you can't really model much in SSRS. Basically I create a class that you pass the 'SERVER' you need to reference to the class like 'http:// /ReportServer'.

private ReportingService2010 _ReportingService = new ReportingService2010();
        private ReportExecutionService _ReportingExecution = new ReportExecutionService();

        private string _server { get; set; }

        public ReaderWriter(string server)
        {
            _server = server;
            _ReportingService.Url = _server + @"/ReportService2010.asmx";
            _ReportingService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            _ReportingExecution.Url = _server + @"/ReportExecution2005.asmx";
            _ReportingExecution.Credentials = System.Net.CredentialCache.DefaultCredentials;
        }

public List<ItemParameter> GetReportParameters(string report)
        {
            try
            {
                return _ReportingService.GetItemParameters(report, null, false, null, null).ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Getting Parameter info threw an error:\n " + ex.Message);
                return new List<ItemParameter> { new ItemParameter { Name = "Parameter Not Found" } };
            }
        }

        public List<CatalogItem> GetChildInfo(string dest)
        {
            try
            {
                return _ReportingService.ListChildren("/" + dest, false).ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Getting Child info of location threw an error:\n\n" + ex.Message);
                return new List<CatalogItem> { new CatalogItem { Name = "Path Does Not exist", Path = "Path Does not exist" } };
            }
        } 
Community
  • 1
  • 1
djangojazz
  • 14,131
  • 10
  • 56
  • 94
  • 1
    Using the web service isn't a problem. I know I can retrieve lists of report objects and lists of parameters from it. What I was looking for was a way to have the web service build that URI for me using values I provide to the web service, but it doesn't seem to exist. I know I can build the URI myself but as I wrote before I try not to reinvent wheels. – JC Ford Jun 12 '13 at 12:52
  • You can traverse a listing from the root or you can get the listings of 'Catalog' Items in .NET. In my part III above the second method of 'GetChildInfo' returns an array of either directories or items in a directory much like a 'dir' command in DOS would. Generally I either query the database for the info of 'ReportServer' or I use a WPF application that implements my class that implements my methods to get the info about either the reports or their parameters. To get the path for the web service you just piece the part next to the root and put in '&' plus commands to the end. – djangojazz Jun 12 '13 at 15:53
1

ListChildren is the way to go. You can always set the second parameter to true to return all catalog items when you have reports in many folders.

Dim items As CatalogItem() = rs.ListChildren(reportPath, True)  
Eric
  • 958
  • 1
  • 11
  • 28