ActiveReports 13
Document Windows Application
ActiveReports 13 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Section Report Walkthroughs > Web > Document Windows Application

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

This walkthrough illustrates how to create a Windows client application that returns the content of a Section report in the Windows Forms viewer.

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

Note: Refer to Document Web Service to set up Web service that returns an ActiveReports document.

To 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.

To 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.

To add a web reference

To add a reference to a web service in Visual Studio that is compatible with the .NET Framework Web service version

  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.

To add a reference to a web service in Visual Studio

  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.

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

To display the report content

  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.

To 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()

To 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();

To display the report content

  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.

To 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()

To 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();

To update the app.config file

Note: You need to update the app.config file if you added the Service Reference to Visual Studio 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.

To run the project

Press F5 to run the project.