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 Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!