How to programmatically read SQL Server Report History?

SQL Reporting Services Query - for SQL Server 2008.

Given that Reporting Services SQL Server has a scheduler that can be used to schedule SQL reports, does anyone know how to programmatically (through C #) read report history from a report server (and then possibly retrieve report results)?

So, after some extra digging, it looks like I need to create a WSDL for the report server and then access the information using the ReportingService object - has anyone done this before (since 2008) and can provide some pointers?

Note: Looks (according to SQL 2008 online books), WSDL address for SQL 2008:

http://server/reportserver/ReportService2005.asmx?wsdl 

If I can achieve this, I will send an answer with the basic steps for its implementation. This is a bit confusing as the documentation is a mixture of SQL 2000 and SQL 2005 references!

+4
source share
2 answers

Well, that’s why I really understood how to accomplish this seemingly impossible task.

Before you begin, let me say that if you are working with SQL Server Reporting Services 2008 (SSRS 08) and have (i.e. you have no choice) to use something like Basic auth, you will only find the world hurts with WCF based on services and IIS. In the future, I will talk about the configuration.

The short answer is as follows:

  • Connect (e.g. new ReportingService2005 () or ReportingService2005SoapClient ())

Note. It's easier to use the old (pre-WCF) ASMX service, but it's not impossible to use the new version of CF. Authentication requires some configuration. There are also some minor syntax changes between versions.

  • Find the report history you are looking for, for example. ReportHistorySnapshot [] history = reportServer.ListReportHistory (@ "/ Reports / MyHandyReport");
  • Get History ID from any snapshot you want (returned from ListHistoryReport)
  • Now use ReportViewer to render the historical report, like any other report, for example:

    ReportViewer rv = new ReportViewer ();
    rv.ProcessingMode = ProcessingMode.Remote;
    rv.ServerReport.ReportServerUrl = new Uri (@ " http: // localhost / reportserver ");
    rv.ServerReport.ReportPath = @ "/ Reports / MyHandyReport";
    rv.ServerReport.HistoryId = historyId;
    //...snip
    byte [] bytes = rv.ServerReport.Render ("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);

Note. You can also use the second WCF web service (ReportExecution2005.asmx? Wsdl) as well as to run reports

+2
source

Well, what soap and extensibility API, maybe they can be used?

+1
source

All Articles