Click here to Skip to main content
Click here to Skip to main content

Publishing Crystal Report as a Web Service

By , 11 Aug 2004
 

Introduction

Web services would be a convenient way of distributing reports, and additional security features can be installed. Being a web service, it is platform neutral and can be accessed from other OS. This 'CodeWalk' is to illustrate the ease with which such such a distribution can be accomplished. The article shows the mechanics of creating a web service, and then it shows how to access this service from a WebForm. This access is not limited to a WebForm, it can also be through a console client, but a different procedure has to be adopted.

On Publishing a Crystal Report as a Web Service

Crystal report as a web service:

Start a new project in Visual Studio [Microsoft Development Environment 2003 Version 7.1.3088]. Choose the web service project template [WebSvc2]. Remove the default file 'service1.asmx'. Import the Crystal Report file into the WebSvc2 folder [ParQry.rpt]. Right click this Crystal Report and pickup 'Publish as web service' from the pop-up menu. Now the service ParQryService.asmx is created. Choose ParQryService.asmx as initial start page and build the solution. Right click and pick up 'View in browser'. You will see the following web page:

On this page, all permitted operations will be listed as shown above. Click on 'Service Description' on this web page, this is the so called '*.wsdl' file, a file that can locate the service: 'http://localhost/WebSVC2/ParQryService.asmx?WSDL'.

The project folder for the web service so created is as shown here:

The Crystal Report published as a service will be available at the website for the above query string.

Testing the functionality of the Web Service

Web Service test rig:

Create a web application [WebSvc2Test]. To the WebForm1.aspx, add a CrystalReportViewer control from the tool box. Add a Button to the page, set Text property of the Button to 'Test Web Crystal Service'. Make some changes to the properties of the CrystalReportViewer1 as shown in this screen shot.

To the Button's Click event, add the following code:

Private Sub Button1_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button1.Click
    CrystalReportViewer1.ReportSource = _
     "http://localhost/WebSVC2/ParQryService.asmx"
End Sub

This sets up the source for the CrystalReportViewer to be fed from the web service called 'ParQryService', on the localhost web site. Build the solution and view the page on the browser. The browser page on loading will appear as in this picture:

Now, click the button and you will be getting the Crystal Report published as a service on the local host, as shown here:

Crystal Report from Web Service

Now, the overall folder structure of the test rig project is shown here:

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

mysorian
Technical Writer Hodentek
United States United States
Member
Worked in the area of electrical discharges, high energy lasers, high voltage technology, plasma technology, lithography, thin film plastics, superconducting thin films, diamond thin films, electron accelerators, and free electron lasers for several years. Mentored/guided MS and PhD students at several universities in USA, Brazil, Australia, and India.
Reading books and photography are my hobbies.
 
Also trained workforce clients with legacy computer skills in web related technologies.
 
I recently authored a beginner level book on MS SQL Server Integration Services. Details available at the following link:
 
http://www.packtpub.com/sql-server-integration-services-visual-studio-2005/book
 
My second book was released in 2008
Learn SQL Server Reporting Services 2008
 
Get book details at the following site:
http://www.packtpub.com/learning-sql-server-2008-reporting-services/book
 
This is for anyone who is interested in Reporting Services a la Microsoft. It has over 50 hands-on exercises and covers all aspects of Reporting Services.
 
Recent new books:
 
Microsoft SQL Azure Enterprise Application Development 2010
-A Comprehensive book on SQL Azure
 
Microsoft Visual Studio LightSwitch Business Application Development 2011
A step-by-step approach that is sure to work

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionShowing Graphs...membershiber1222 Feb '09 - 21:00 
Thanks for this great article.
But I cant view graphs from the Crystal reports in the web services, only details.
 
can u please help me?
QuestionCrystal Reports Web Service Return PDF Streammemberabiondo12 Apr '07 - 10:41 
This is cool, but what would be great is if you can take a report dynamically query and display only a report for a specific user and output it as a pdf. I know sites like Smith Barney do this for their statements. Does anyone have any examples?
 
thanks,
Anthony
AnswerRe: Crystal Reports Web Service Return PDF Streammembermysorian12 Apr '07 - 11:28 
Thanks. Actually this is possible with parameteric queries and as for as user customized queries perhaps the database has permissions enforced.
QuestionUse in WinFormsmemberthe bill19 Mar '07 - 22:29 
How can i use this in my desktop application, so that i can host my reports on my web server for a LAN?
AnswerRe: Use in WinFormsmembermysorian20 Mar '07 - 2:28 
Using the asmx file you will have to create a windows client program to call the service from your desktop.
 
You can find some examples at this link:
http://hodentek.blogspot.com/2007/02/links-to-my-articles-on-web-services.html[^]
 

GeneralError when consuming Report from a webservicemembermew_lobo16 Jul '06 - 16:42 
Hi,
 
I'm using Visual Studio.Net 2005 with Crystal reports. I tried the tutorial on Publishing and consuming a report as a webservice from MSDN. When I run the windows form, I get error messages saying that the report failed to load. It works fine if I give the file path to the .rpt file, but when its been published as a webservice and I give the URL, I get the error. I have all the sample reports and database(MS Access Db). If anyone knows, plz let me know.
 
Thx,

 
Mahesh
GeneralRe: Error when consuming Report from a webservicemembermysorian16 Jul '06 - 17:18 
I am sorry I do'nt have CR on my computer and if you are interested in knowing about publishing reprots to your intranet you may want to check out some articles at:
 
http://www.angelfire.com/vt2/hodentek
 
or my bolg at:
http://hodentek.blogspot.com/
GeneralRe: Error when consuming Report from a webservicemembermew_lobo16 Jul '06 - 21:44 
Ok, Thanks.
QuestionPublish Crystal Reports to WebmemberDoug726 Mar '06 - 8:28 
Regards,
I´m trying to deploy my web application in a shared hosting place, but the Crystal Report XI pages does not work. I read your article and tried to do that as a web service, but it is not still working.
Have you ever tried to use Crystal Report to do this? Is that even possible? If so, what are the steps to follow up?
Thanks in advance for any help that you can offer.
 
Douglas Borrero
AnswerRe: Publish Crystal Reports to Webmembermysorian6 Mar '06 - 9:07 
No, O have not tried what you are asking for. I have not worked with Crystal Reports for quire some time. What version of CR is referenced by Crystal Report XI pages?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 12 Aug 2004
Article Copyright 2004 by mysorian
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid