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:
- Adding a reference to a Web service to the project
- Setting the report data source to the one returned by the Web service
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). |
To add a reference to a web service to the project
- From the Project menu, select Add Service Reference.
- In the Add Service Reference window that appears, click Advanced button.
- In the Service Reference Settings window that appears, click Add Web Reference button.
- In the Add Web Reference window that appears, click the Web services on the local machine link.
- 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.)
- Click the Go button, and then click the Add Reference button when the Web Service is recognized.
To add a reference to a web service in Visual Studio 2008 or 2010
- From the Project menu, select Add Service Reference.
- 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.)
- Click the Go button, and then click the OK button when the Web Service is recognized.
To set the report data source to the one returned by the Web service
- Double-click the gray area below the report. This creates an event-handling method for the ReportStart event.
- 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.
To 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"
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";
To set the report data source (for Visual Studio 2008 or 2010)
- Double-click the gray area below the report. This creates an event-handling method for the ReportStart event.
- 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.
To 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"
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";
To 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. |
- In the Solution Explorer, open the app.config file.
- In the tag <binding name = "ServiceSoap"...>, set maxBufferSize and maxReceivedMessageSize to some large number, for example, 200500.
- In the next tag <readerQuotas...>, set maxArrayLength to some large number, for example, 60500.