ActiveReports 15 .NET Edition
ActiveReports 15 User Guide / Samples and Walkthroughs / Walkthroughs / Common Walkthroughs / Web / DataSet Web Service
In This Topic
    DataSet Web Service
    In This Topic

    With ASP.NET, you can set up a Web Service that returns a dataset to use in ActiveReports. This walkthrough illustrates how to create one.

    This walkthrough is split 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).

    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 Application to create a empty web application.
    3. Change the name of the project.
    4. Click OK to open the new project in Visual Studio.

    To create the Web Method

    1. From the Project menu, select Add New Item.
    2. In the Add New Item dialog that appears, select Web Service (asmx) and change the name of the web service.

    In the WebService, replace the existing <WebMethod()> _ and HelloWorld function with code like the following.

    To write the code in Visual Basic.NET

    Visual Basic.NET code. Paste OVER the existing WebMethod.
    Copy Code
    Private connString As String
    <WebMethod(Description:="Returns a DataSet containing all Products")> _
    Public Function GetProduct() As Data.DataSet
    connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[User Folder]\Samples15\Data\Nwind.mdb"
    Dim adapter As New Data.OleDb.OleDbDataAdapter("select * from products", connString)
    Dim ds As New Data.DataSet()
    adapter.Fill(ds, "Products")
    Return ds
    End Function

    To write the code in C#

    C# code. Paste OVER the existing WebMethod.
    Copy Code
    private static string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = [User Folder]\\Samples15\\Data\\nwind.mdb";
    [WebMethod(Description="Returns a DataSet containing all Products")]
    public Data.DataSet GetProduct()
       System.Data.OleDb.OleDbDataAdapter adapter;
    System.Data.DataSet ds;
    adapter = new System.Data.OleDb.OleDbDataAdapter("select * from products", connString);
    ds = new System.Data.DataSet();
    adapter.Fill(ds, "Products");
    return ds; }

    To test the Web Service

    1. Press F5 to run the project.
    2. If the Debugging Not Enabled dialog appears, select the option that enables debugging and click OK to continue.
    3. In the list of supported operations, click the GetProduct link. (The description string from the code above appears below the link.)
    4. Click the Invoke button to test the Web Service operation.
    5. If the test is successful, a valid XML schema of the Northwind products table displays in a new browser window.
    6. Copy the URL from the browser for use in the Web Reference of your DataSet Windows Application.

    To publish the Web Service

    1. In the Solution Explorer, right-click the project name and select Publish.
    2. In the Publish Web window that appears, select Custom option to create a custom profile and click OK.
    3. Enter localhost in the Server field and "SiteName"/WebServiceName in the Site name field.
      Note: Get the SiteName from the Internet Information Services Manager.
    4. Click the Publish 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 to add WebServiceName.asmx to the url and press Enter.

    For information on consuming the DataSet Web Service in an ActiveReport, see DataSet Windows Application.