Enterprise Software

Web services for reporting, part 1

In this article from Builder AU Technical Editor David McAmis, learn how to create XML web services for reporting from your .NET application.

Web services can be used for a number of different uses, but what about reporting? Crystal Reports has long been the de-facto standard for reporting in Visual Studio and with the release of Visual Studio.NET you can now convert report files into Web services. You can then consume these Web services and deliver reports to users in and outside of your organisation. In this article we'll look at how to create a Web service from an existing report file and in part 2 of the article we'll look at how to consume the Web service you created.

Note: For this tutorial we will be using Visual Studio.NET 2003. Before you begin, make sure you have installed Visual Studio with all of the Crystal Reports components, including the option for "Crystal Web services".

To start, open Visual Studio from the Start menu and select File > New > Project to create a new ASP.NET Web Application. In this example, we are going to call the project "ReportService".

Once you have created your project, you will need to create or add an existing Crystal Report that we will be converting into a Web service. If you don't have a report handy, you can always use one of the sample reports that ships with Visual Studioâ€"they are located in C:Program FilesMicrosoft Visual Studio .NET 2003Crystal ReportsSamplesReports and in this example we are going to use the "World Sales Report.rpt" found in the General Business examples folder.

To add an existing report to your project, select Project > Add Existing Item, and change the drop-down list at the bottom of the dialog to "Crystal Reports" and browse for the report file you want to add.

Next, locate the report in the Solution Explorer and right-click directly on top of the report. In the right-click menu there is an option to "Publish as Web service". This will generate an ASMX file that you can view by right-clicking on the file name (in this case "World Sales ReportService.asmx") and selecting "View in Browser".

This preview will show you all of the operations that are allowed for your Web service, including:

• DrillGraph
• Refresh
• FindText
• GetPage
• GetTotaller
• TestReport
• GetGroupLevelData
• FindGroup
• GetLastPageNumber
• GetReportInfo
• Export

There is also a link to the formal Web service definition written using WSDL (Web Service Definition Language).

From this point, you can use this Web service in conjunction with the Crystal Report viewer to view the original report and that is where we will pick up in part 2 of this article.

Editor's Picks

Free Newsletters, In your Inbox