Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

18.01 Web Services

Creating reports as Report Web Services (RWS) enables you to deliver reports using SOAP via an HTTP protocol. There are no issues with worrying about the report being blocked by security or network constraints.

There are two parts to viewing reports as a web service. The first part is to build the web service application and publish the report. The second is creating an application that consumes the report. Fortunately, Visual Studio .NET makes creating and consuming web services almost trivial.

First create a new Web Services project using the Visual Studio IDE. Click on the menu options File > New > Web Site.



Figure 18-1. Create new web services project

Be careful to set the Location property to HTTP. This tells Visual Studio to update the IIS Settings so that the report is in the INetPub/WWWRoot folder and runs under LocalHost. If you use the File option, the URL uses a temporary URL each time the project runs and this can’t be referenced directly by another application. You will have to update IIS manually to create a new virtual directory that accesses the web service directly.

When the web site opens, add a new report to it. You can either use the Report Wizard to build the report from scratch or add an existing report.

In my example, I selected the EmployeeList report I built in an earlier chapter. Right click on the project name in the Solution Explorer window and select Add > Add Existing Item. After the dialog box opens browse to where your report is located and select it.

To publish the report as a web service, right-click on it in the Solution Explorer window and select Publish as Web Service.



Figure 18-2. Publish the report as a web service.

This adds a new web service class to your project. It is automatically named the same as the report name with “service” appended to it. The file extension is .asmx.



Figure 18-3. The new report web service class.

That’s all there is to it! Test the report web service by right-clicking on it in the Solution Explorer and selecting Set As Start Page. Then run the application. A web browser will open up with the following page displayed.



Figure 18-4. Testing the Report Web Service with a browser.

The browser shows you all the operations that the report supports. You can click on each one and find see a sample SOAP request and response. Look in the address bar for the full URL of the report web service. This is the URL that is assigned to the viewer control of the application that consumes this service.