Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

18.01 Introducing 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.



Figure 18-1. Create new web services project

When the project opens, add a new report to it. 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.

Reports that are published as a web service cannot have a comment on the first line of the record selection formula. The first line should be a standard formula.


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.