RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Automating Smart-Client Report Deployments

Building reports is often easier than getting them into users' hands and making sure they're used correctly, but now you can use the SQL Server Reporting Services Web service to automate deployment and control execution of reports.

his article will show you how to use Microsoft SQL Server's Reporting Services Web service to install your reports and execute them from a smart client application.

If you use Reporting Services in a corporate environment, deploying reports and data sources is easy, just configure your test, staging, and live servers in Visual Studio when you create your project. When you've completed your report, select the appropriate solution configuration, right click your report, choose Deploy, and you're done. The Web-based user interface is flexible and end users can run your reports easily.

But what if you want your reports to run from a smart client application rather than from the Web interface? You might want to use the flexibility of Reporting Services to automatically render your report as an Excel spreadsheet or Adobe PDF file without end users even knowing that Reporting Services is involved.

Or suppose you need to deploy reports to hundreds or thousands of external customers? You need a way to automate report deployment so that end users don't need to figure out how to install your reports—so that installation happens automatically. The solution is to use the Reporting Services Web service from within your application.

Both the Report Designer component in Visual Studio and the Web-based Report Manager use the Reporting Web service, so you can use the Web service from your own applications. All the reporting engine's capabilities are still available, including the ability to create users and roles, install reports and data sources, examine existing configuration settings, schedule reports, and execute reports interactively.

Creating the Web Service Proxy Class
As with all .NET Web service clients, you need to write or auto-generate a Web service client proxy class for the Reporting Services Web service. To auto-generate your Web proxy from within Visual Studio, right click the References item in the Solution Explorer, and select "Add Web Reference" (see Figure 1).

Figure 1. Adding a Web Reference: To add a Web Reference, right click on References in the Solution Explorer and select the "Add Web Reference" item.
In the "Add Web Reference" dialog, enter the URL of your reporting server's Web service—this is not the same URL you use to access the Web user interface. In a default setup, the URL is the reporting server name followed by /ReportServer/reportservice.asmx. For example, for a reporting services setup on your local development machine, use the URL http://localhost/ReportServer/reportservice.asmx.

When the Add Web reference dialog displays the Web service information, enter a Web reference name (I used "ReportServer" for the sample application), and click "Add Reference". Visual Studio will automatically create a proxy class for you to use.

Web Service Proxy Setup
After creating an instance of your Web service proxy, make sure you set the Web service URL and Credentials properties:

       mobjReportServer = _
         New ReportServer.ReportingService
       mobjReportServer.Url = URL
       mobjReportServer.Credentials = _

Under some configurations of Windows and IIS, if you don't set the proxy's credentials, your Web service calls will fail, even if you are logged in as administrator. That's because .NET does not pass the credentials of the current user to the Web service by default. You can use the NetworkCredential class rather than the DefaultCredentials class shown in the preceding code to force the Web service proxy to use the credentials of a specific user.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date