Monday, August 10, 2009

Generating Reports Through WebService...

Usually once the reports are developed, they are deployed to the report server and the end users can view the report from the reporting portal. I ran into a situation where i had to perform data driven subscription kind of reports. Here the requirement at a set time of the day, the reports had to be generated in a .pdf format and stored in a network folder. In order to accomplish this, the reportexecution2005.asmx web service was used. The reference material at the MSDn site helped me guide to accomplish this effort. The .asmx file mentioned above is present in the report server. I added this file as a web reference to my project, once this was done there are methods which need to be used to generate the report. The methods are LoadReport,Render,GetExecutionInfo. The render method performs the actual rendering of the report. The output is then put out to the pdf file at the required location using the FileStream object. This whole thing was done in C# console application.

Sample Code:

ReportExecutionService rs = new ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://myserver/reportserver/reportexecution2005.asmx";

The link to the msdn article:
http://msdn.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsexecutionservice2005.reportexecutionservice.render.aspx

No comments:

Post a Comment