ActiveReports Developer 7
Document Windows Application
See Also Support Forum
ActiveReports Developer 7 > ActiveReports Developer Guide > Samples and Walkthroughs > Walkthroughs > Web Services (Std Edition) > Document Windows Application

Glossary Item Box

In ActiveReports Developer, you can use a Web Service that returns the content of an ActiveReport to show in the Windows Forms viewer control.

This walkthrough illustrates how to create a Windows client application that returns the content of an ActiveReport Developer in the Windows Forms viewer.

This walkthrough builds on the Document Web Service walkthrough and is split up into the following activities:

ShowTo create a Visual Studio project

  1. From the File menu, select New, then Project.
  2. In the Templates section of the New Project dialog, select Windows Application.
  3. Change the name of the application to ARDocumentClient.
  4. Click OK to open the project.

ShowTo add the Viewer control

  1. From the Visual Studio toolbox, drag the ActiveReports Viewer control onto the form.
  2. Change the Dock property for the viewer control to Fill, and resize the form to accommodate a report.

ShowTo add a web reference

ShowTo add a reference to a web service in Visual Studio 2008 or 2010 that is compatible with .NET Framework 2.0 Web service

  1. From the Project menu, select Add Service Reference.
  2. In the Add Service Reference window that appears, click the Advanced button.
  3. In the Service Reference Settings window that appears, click Add Web Reference button.
  4. From the Project menu, select Add Web Reference.
  5. Type in the address of the .asmx file for the ActiveReports Document Web Service you created in the previous walkthrough. For example: http://localhost/ARDocumentWS/Service.asmx
  6. Click the Add Reference button when the Web Service is recognized.

ShowTo add a reference to a web service in Visual Studio 2008 or Visual Studio 2010

  1. From the Project menu, select Add Service Reference.
  2. In the Add Service Reference that appears, type in the address of the .asmx file for the ActiveReports Document Web Service you created in the previous walkthrough. For example:  http://localhost/ARDocumentWS/Service.asmx
  3. Click the Go button, and then click the OK button when the Web Service is recognized.

ShowTo display the content returned by the Document Web Service in the viewer

ShowTo display the report content (for Visual Studio 2008 or 2010 compatible with .NET Framework 2.0 Web service)

  1. Double-click Form1 to create an event-handling method for the Form1_Load event.
  2. Add code to the handler to display the document Web service content in the viewer.

The following example shows what the code for the method looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
Dim ws As New localhost.Service
Me.Viewer1.Document.Content = ws.GetProductsReport()

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
localhost.Service ws = new localhost.Service();
this.viewer1.Document.Content = ws.GetProductsReport();

ShowTo display the report content (for Visual Studio 2008 or 2010)

  1. Double-click on Form1 to create an event-handling method for the Form1_Load event.
  2. Add code to the handler to display the document Web service content in the viewer.

The following example shows what the code for the method looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
Dim ws As New ServiceReference1.ServiceSoapClient()
Me.Viewer1.Document.Content = ws.GetProductsReport()

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
ServiceReference1.ServiceSoapClient ws = new ServiceReference1.ServiceSoapClient();
this.viewer1.Document.Content = ws.GetProductsReport();

ShowTo update the app.config file

Note: You need to update the app.config file if you added the Service Reference to the Visual Studio 2008 or 2010 project in the previous section.
  1. In the Solution Explorer, open the app.config file.
  2. In the tag <binding name = "ServiceSoap"...>, set maxBufferSize and maxReceivedMessageSize to some large number, for example, 200500.
  3. In the next tag <readerQuotas...>, set maxArrayLength to some large number, for example, 60500.

ShowTo run the project

Press F5 to run the project.

See Also

©2014. ComponentOne, a division of GrapeCity. All rights reserved.