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:
- 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
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 create the Web Method
In the App_Code/Service.vb or Service.cs file that displays by default, 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=C:\Users\[User Name]\Documents\ComponentOne Samples\ActiveReports 8\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 = C:\\Users\\[User Name]\\Documents\\ComponentOne Samples\\ActiveReports 8\\Data\\nwind.mdb";
[WebMethod(Description="Returns a DataSet containing all Products")]
public Data.DataSet GetProduct()
{
Data.OleDb.OleDbDataAdapter adapter;
Data.DataSet ds;
adapter = new Data.OleDb.OleDbDataAdapter("select * from products", connString);
ds = new Data.DataSet();
adapter.Fill(ds, "Products");
return ds;
}
|
To test the Web Service
- Press F5 to run the project.
- If the Debugging Not Enabled dialog appears, select the option that enables debugging and click OK to continue.
- In the list of supported operations, click the GetProduct link. (The description string from the code above appears below the link.)
- Click the Invoke button to test the Web Service operation.
- If the test is successful, a valid XML schema of the Northwind products table displays in a new browser window.
- Copy the URL from the browser for use in the Web Reference of your DataSet Windows Application.
To publish the 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 DataSet Web Service in an ActiveReport, see DataSet Windows Application.
See Also