ActiveReports 11
Document Web Service
ActiveReports 11 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Section Report Walkthroughs > Web > Document Web Service

With ASP.NET and ActiveReports, you can set up a Web Service that returns a report document which can be shown in a report viewer control.

This walkthrough illustrates how to create a Web Service that returns the contents of an ActiveReports as a byte array.

This walkthrough 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 Basic Data Bound Reports for a section report.

When you have completed this walkthrough, you will have a Web Service that returns the contents of an ActiveReports as a byte array.

To create an ASP.NET Web Service project

  1. From the File menu, select New Project.
  2. In the New Project dialog that appears, select ASP.NET Web Service Application.
  3. Change the name of the project.
  4. Click OK to open the new project in Visual Studio.

To write the code to create the Web Method

  1. On the Service.vb or Service.cs tab is the code view of the Service.asmx file.
  2. Replace the existing WebMethod and HelloWorld function with the following code.

The following code demonstrates how you create the Web Method for a section report.

Visual Basic.NET code. REPLACE the existing WebMethod and function with this code.
Copy Code
<WebMethod( _Description:="Returns a products report grouped by category")> _
Public Function GetProductsReport() As Byte()
Dim rpt As New rptProducts()
rpt.Run()
Return rpt.Document.Content
End Function
C# code. REPLACE the existing WebMethod and function with this code.
Copy Code
[WebMethod(_Description = "Returns a products report grouped by category")]
public byte[] GetProductsReport()
{
rptProducts rpt = new rptProducts();
rpt.Run();
return rpt.Document.Content;
}

To test the Document Web Service

  1. Press F5 to run the project. The Service page appears in your browser.
  2. In the list of supported operations at the top, click GetProductsReport.
  3. Click the Invoke button to test the Web Service operation.
  4. If the test is successful, you will see the binary version of the contents of rptProducts.

To publish the Document Web Service

  1. In the Solution Explorer, right-click the project name and select Publish.
  2. In the Publish Web window that appears, enter locahost in the Service URL field and "SiteName"/WebService in the Site/application field.
    Note: Get the SiteName from the Internet Information Services Manager.
  3. Select the Mark an IIS application on destination option and click the OK button.

To check the configuration in IIS

  1. Open Internet Information Services Manager.
  2. In the Internet Information Services Manager window that appears, expand the tree view in the left pane until you see the Web Service you had added in the steps above.
  3. Right-click the Web Service select Manage Application then Browse.
  4. In the browser that appears, go to the Address bar and add \Service1 to the url.

For information on consuming the Document Web Service in a viewer, see Document Windows Application.

See Also