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

Glossary Item Box

You can use a Web Service that returns a dataset as the data source for your reports in Windows applications. This walkthrough illustrates how to create a Windows client application that uses the dataset Web Service as the data source for an ActiveReports Developer.

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

Note: For the information on how to connect your report to data and how to create the report layout, please see Single Layout Reports (for a page report) or Basic Data Bound Reports (for a section report).

ShowTo add a reference to a web service to the project

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 Advanced button.
  3. In the Service Reference Settings window that appears, click Add Web Reference button.
  4. In the Add Web Reference window that appears, click the Web services on the local machine link.
  5. Click the link to the virtual directory you created in the previous walkthrough. You can get the address by running the project from the previous walkthrough and copying the url from the address in the browser. (It will look something like http://localhost:####/DataSetWS/Service.asmx where #### is the port number.)
  6. Click the Go button, and then click the Add Reference button when the Web Service is recognized.

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

  1. From the Project menu, select Add Service Reference.
  2. In the Add Service Reference window that appears, type in the address of the virtual directory you created in the previous walkthrough. You can get the address by running the project from the previous walkthrough and copying the url from the address in the browser. (It will look something like http://localhost:####/DataSetWS/Service.asmx where #### is the port number.)
  3. Click the Go button, and then click the OK button when the Web Service is recognized.

ShowTo set the report data source to the one returned by the Web service

ShowTo set the report data source (for Visual Studio 2008 or 2010 compatible with .NET Framework 2.0 Web service)

  1. Double-click the gray area below the report. This creates an event-handling method for the ReportStart event.
  2. Add code to the handler to use the web service dataset in the report.

    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 ReportStart event Copy Code
    Dim ws As New localhost.Service
    Dim ds As DataSet()= ws.GetProduct()
    Me.DataSource = ds
    Me.DataMember = "Products"                                        
    

    ShowTo write the code in C#

    C# code. Paste INSIDE the ReportStart event. Copy Code
    localhost.DataSetWS ws = new localhost.Service;
    DataSet ds = ws.GetProduct();
    this.DataSource = ds;
    this.DataMember = "Products";                                        
    

ShowTo set the report data source (for Visual Studio 2008 or 2010)

  1. Double-click the gray area below the report. This creates an event-handling method for the ReportStart event.
  2. Add code to the handler to use the web service dataset in the report.

    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 ReportStart event. Copy Code
    Dim ws As New ServiceReference1.ServiceSoapClient()
    Dim ds As DataSet = ws.GetProduct()
    Me.DataSource = ds
    Me.DataMember = "Products"
    

    ShowTo write the code in C#

    C# code. Paste INSIDE the ReportStart event. Copy Code
    ServiceReference1.ServiceSoapClient ws = new ServiceReference1.ServiceSoapClient();
    DataSet ds = ws.GetProduct(); 
    this.DataSource = ds;
    this.DataMember = "Products";
    

ShowTo update the app.config file (Visual Studio 2008 or 2010 project)

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.
©2014. ComponentOne, a division of GrapeCity. All rights reserved.