Creating a Crystal Report Web Service


Another notable facet of working in the .NET environment is the capability to create a Crystal Report that is available as a web service and that can be consumed by other applications. To highlight how simply this can be accomplished, Figure 29.10 shows Visual Studio after having added an existing sample Crystal Report (World Sales Report) to a new web service project. Enacting the Publish as Web Service function from the right-click menu creates an asmx file with the name of the report prefixing the text service.

Figure 29.10. Visual Studio .NET enables the quick and easy publishing of the World Sales Report as a web service.


You can test this Crystal Reports web service out by setting the corresponding WorldSalesReportService.asmx file as the starting page for this web service. This option is accessed through the right-click menu of the .asmx object and can be viewed in the browser by accessing http://localhost/WebServiceName/WorldSalesReportService.asmx (see Figure 29.11). You will be presented with a list of the different operations that the report web service supports. You can view sample SOAP request-and-response information using placeholders by clicking on any of the available operations.

Figure 29.11. Viewing the Crystal Reports web service and its associated operations.


To use this web service from another application, you can quickly create a new ASP.NET application called ShowSalesReport (or anything you prefer) and after adding a CrystalReportViewer from the new form's toolbox, bind the ReportSource to either the web service or the involved web service's URL as follows:

[View full width]

CrystalReportViewer1.ReportSource = http://localhost/WebService1/World Sales ReportService .asmx OR CrystalReportViewer1.ReportSource = New localhost.WorldSalesReportService


Tip

When adding a Crystal Reports' web service, it is recommended that you eliminate any spaces from the created .asmx web service file. You might experience problems in attempting to click through on the report operations provided by the Crystal Reports' web service when spaces have not been eliminated. Also, remember to build your solutions/projects before testing them in your browser.





Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net