In part 1 of this article we looked at how to create an XML Web service from an existing Crystal Report. In this article, we are going to look at how to consume that Web service from within your own Windows application.

To start, you will need to create a new Windows application within Visual Studio.NET by selecting File > New > Project. In this instance, we are going to create a VB.NET application and call it "ConsumeWebService".

Once you have created your new project, a default form will be created (Form1) and we are going to use this form to display the report served up by your Web service. The first thing we need to do is to drag and drop the Crystal Report viewer onto your form.

In the toolbox, select the section marked "Windows Forms" and locate the icon marked CrystalReportViewer. Click this icon and then use your mouse to draw the Crystal Report Viewer onto your form in the size and shape you want.


Note: You also may want to set the DOCK property of the viewer to "Fill" so it will fill the entire form when the project is compiled and run

Next, we need to set the let the viewer know where to retrieve the report, which we will do in the Form1_Load subroutine. The viewer that you added to your form will be called "CrystalReportViewer1" by default and there is a "ReportSource" property that you can set to tell the viewer where to get the report. In this case, it is the Web service we created in part 1 of this article, as shown in the code below:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

CrystalReportViewer1.ReportSource = "http://localhost/ReportService/World%20Sales%20ReportService.asmx"

End Sub


Note: Since the report name originally had spaces in it, the spaces in the URL have been replaced with escape characters (%20).

This is the only line of code you need to make this solution workââ,¬"when you compile and run your application, the report displayed in the viewer will be retrieved from the Web service.

And this is just a simple exampleââ,¬"you could also consume reporting Web services from ASP, ASP.NET and COM Web applications, as well as Windows applications and any development environment that supports the Crystal Reports Viewer.

Related links

Comments

1

ramiro valdez - 03/03/06

that works if the report is created using a "direct" SQL connection...but if the report was created using a DataSet as Database?....in what moment or method should I fill the dataset on the exposing webservice?

» Report offensive content

2

Marlene Deyo - 11/08/07

How do I eliminate the login prompt at runtime to the database that the web service's Crystal Report uses? I know how to do this when the Crystal Report is in the Windows Application, but now that I've moved it to a Web Service, I don't know what object I can link my ConnectionInfo to. Thanks.

» Report offensive content

3

Marlene Deyo - 11/08/07

How do I eliminate the login prompt at runtime to the database that the web service's Crystal Report uses? I know how to do this when the Crystal Report is in the Windows Application, but now that I've moved it to a Web Service, I don't know what object I can link my ConnectionInfo to. Thanks.

» Report offensive content

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

3

Marlene Deyo - 08/11/07

How do I eliminate the login prompt at runtime to the database that the web service's Crystal Report uses? I ... more

2

Marlene Deyo - 08/11/07

How do I eliminate the login prompt at runtime to the database that the web service's Crystal Report uses? I ... more

1

ramiro valdez - 03/03/06

that works if the report is created using a "direct" SQL connection...but if the report was created using a DataSet as ... more

Log in


Sign up | Forgot your password?

  • Staff Aussies to pay more for Win 7

    If you are looking to make some money in these troubled times, perhaps importing copies of Windows 7 could be for you. Read more »

    -- posted by Staff

  • Staff Firefox: Greens want it, 3.5rc2 not up to par

    This week's roundup looks at the situation surrounding a campaign to change Outlook HTML renderer, a Greens MP wants to install Firefox but is restricted and all the photos from the iPhone 3GS launch. Read more »

    -- posted by Staff

  • Chris Duckett Microsoft misses the Outlook point

    Ask designers which mail program is the bane of their existence, and you'll find that Outlook tops the list. The reason why the most popular email reader is also the most painful is simple: it uses Word to render HTML emails. Read more »

    -- posted by Chris Duckett

What's on?