IBM Database Add-Ins for Visual Studio  

Generating Web Methods

By using the IBM Database Add-Ins for Visual Studio, you can generate ADO.NET code and add the generated files to an ASP.NET Web Services project. The code is generated in the language of the project that the code is added to. The generated methods are marked as Web methods. You can build your project and deploy the Web methods as a Web service.

With Microsoft ASP.NET AJAX, you can call an ASP.NET Web service from the browser by using client script. If you use this feature, the code attribute ScriptService is added to each generated Web method. The following example in C# shows a generated Web service with the ScriptService attribute:

    [ScriptService]
    public class SimpleWebService : System.Web.Services.WebService
    {
    [WebMethod]
    public string EchoInput(String input)
    {
        // Method code goes here.
        }
    }

Prerequisite:  A Visual C# or Visual Basic ASP.NET Web Service Web site must be open before you can generate Web methods.

To generate Web methods:

  1. In the Server Explorer, right-click a table, view, procedure, or function (DB2, IDS) under your IBM data connection, and then select Generate Web Methods on the shortcut menu.

    The Generate Web Methods window opens.

  2. Select an ASP.NET Web Service Web site project from the list of available projects in the currently open solution.
  3. Optional: Change the predefined name of the Web service that the Web methods can be deployed as.
  4. For each type of command that you want to include as a Web method, perform the following steps:
    1. Select the Include <command_name> check box.
    2. If a predefined statement for the command is displayed, optionally change it; otherwise, type a new statement.
  5. Optional: To make the Web service accessible from script, select the Enable scripting check box.
  6. Click OK.

Files that contain ADO.NET code for Web methods for the selected SQL statements are generated. You can build this project to deploy the Web service.


See Also

Using Visual Studio 2008 Technology in IBM Database Add-Ins for Visual Studio


.NET Development Forum   DB2 FAQs   IDS FAQs

© Copyright IBM Corporation 2002, 2019. All Rights Reserved.