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:
- Creating an ASP.NET Web Service project
- Adding code to create the Web Method
- Testing the Web Service
- Publishing the Web Service
- Creating a virtual directory in IIS
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
- From the File menu, select New Project.
- In the New Project dialog that appears, select ASP.NET Web Service Application.
- Change the name of the project.
- Click OK to open the new project in Visual Studio.
To write the code to create the Web Method
- On the Service.vb or Service.cs tab is the code view of the Service.asmx file.
- Replace the existing WebMethod and HelloWorld function with the following code.
The following code demonstrates how you create the Web Method for a .
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
- Press F5 to run the project. The Service page appears in your browser.
- In the list of supported operations at the top, click GetProductsReport.
- Click the Invoke button to test the Web Service operation.
- If the test is successful, you will see the binary version of the contents of rptProducts.
To publish the Document Web Service
- In the Solution Explorer, right-click the project name and select Publish.
- 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.
- Select the Mark an IIS application on destination option and click the OK button.
To check the configuration in IIS
- Open Internet Information Services Manager.
- 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.
- Right-click the Web Service select Manage Application then Browse.
- 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.