Skip to main content

skip to main content

developerWorks  >  Information Management | XML | SOA and Web services  >

Build a pureXML application in DB2 for z/OS, Part 2: Web enablement through Universal Services

developerWorks
Go to the previous pagePage 6 of 11 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
3455 KB (48 pages)

Get Adobe® Reader®

Discuss

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


Developing Universal Services

If you want to modify the Universal Services, the easiest way of doing so is through IBM Data Studio Developer. Maybe you want to add a parameter or create additional operations like dedicated XPath queries. Included as part of the tutorial download is a zip file containing the Web service that can be imported into Data Studio for modification.

IBM Data Studio Developer is an integrated Eclipse-based development environment for creating and testing database applications with most functions available for download free of charge, including data Web services. (See Resources for a link to download Data Studio Developer.)

This section includes detailed instructions on how to import and configure the Data Studio project. For more information on developing Web services using Data Studio, refer to some of the articles listed in the Resources section.

Import Universal Services project to Data Studio

This tutorial assumes that Data Studio has been installed and that it has been started using the data perspective.

  1. Right-click on the space in the Data Project Explorer, and select Import:

    Figure 47. Import project into Data Studio, step 1
    Screenshot showing how to import project into Data Studio, step 1

  2. Select Existing Projects into Workspace, and click on Next:

    Figure 48. Import project into Data Studio, step 2
    Screenshot showing how to import project into Data Studio, step 2

  3. Enter the destination of the file or browse to find it, and click on Finish:

    Figure 49. Import project into Data Studio, step 3
    Screenshot showing how to import project into Data Studio, step 3

  4. The project will appear in the Data Project Explorer. Click on the project. You will be asked if you want to edit the connection profile. Click on Edit now:

    Figure 50. Configure database connection, step 1
    Screenshot showing how to configure database connection, step 1

  5. You then get a list of connections to choose from. Select Universal Services Database Connection1, and click on Edit:

    Figure 51. Configure database connection, step 2
    Screenshot showing how to configure database connection, step 2

  6. In the "Properties for Universal Database Connection1" window, select Driver Properties from menu on the left:

    Figure 52. Configure database connection, step 3
    Screenshot showing how to configure database connection, step 3

  7. Enter your own values for the Database (DB2 location name), Host, Port number, User name, and Password fields, then click on Test Connection:

    Figure 53. Configure database connection, step 4
    Screenshot showing how to configure database connection, step 4

  8. Click OK to the receipt.
  9. Click OK in the "Universal Services Database Connection1 Properties" window.
  10. Click on Finish in the Connection window.
  11. Expand the project folder, and in your "Data Project Explorer", you should see the following contents: A folder structure with main folders SQL Scripts, Stored Procedures, User-Defined Functions, Web Services, and XML. The Web Services folder contains a subfolder named Universal Services, containing the services you are going to modify. The XML folder contains subfolders WSDL, XML Documents, XML Schema, and XSLT.

    Figure 54. Universal Services project contents
    Screenshot showing the Universal Services project contents

At this point you are ready to modify the Web services. You might want to change one of the existing operations, for example, by adding a parameter or adding operations to the Web service. For more information on how to use Data Studio to develop Web services, see Resources.

When you have made your modification (or even without modifications), you can deploy your Web service.

  1. Right-click on the Web services folder, and select Build and Deploy:

    Figure 55. Deploy Web service, step 1
    Screenshot showing how to deploy Web service, step 1

  2. In the "Deploy Web Service" window, choose which Web server to use from the drop-down menu.
  3. Choose whether to deploy to the Web server or just build the .war file. Here, just build the .war file, as the other option requires some configuration of the Web server in Data Studio.
  4. Make sure the location name is correct, then click on Finish:

    Figure 56. Deploy Web service, step 2
    Screenshot showing how to deploy Web service, step 2

A message in the Workspace log shows that the Web service has been deployed together with the destination of the .war file:


Figure 57. Deploy Web service, step 3
Screenshot showing how to deploy Web service, step 3

Finally, you have to deploy the .war file to the chosen Web server. (Refer to the "Deploying the Web servers" section.)

In the Universal Services bundle, an XHTML document defines a full Web page, providing a user interface for invoking the Web service operations. When modifying the operations through Data Studio, this XHTML document may no longer be applicable, but it can be updated manually to cater for the changes.

The XHTML document contains forms that collect arguments and generate HTTP POST requests to the Web server. As an example, the form for the getXMLDocumentByKey operation is shown in Listing 4:


Listing 4. XHTML for invoking operation getXMLDocumentByKey

<form name="testServices_getXMLDocumentByKey"  
      action="rest/UniversalServices/getXMLDocumentByKey"   
      method="post">
  <tr class="row-dark" >
    <td>getXMLDocumentByKey</td>
    <td align="right">ID:</td>
    <td align="center">
       <input type="text" name="p1" size="40" />
    </td>
    <td align="center">
      <input type="submit" value="Invoke" />
    </td>
  </tr>
</form>

You can see that the name of the operation is part of the action URL and that the form field for the single argument is named p1 (and p2, p3, and so on for subsequent arguments).

Alternatively, the individual operations of the Web service can be invoked directly through the HTTP GET method. Listing 5 shows example of URLs for each of the supplied operations. Note that parameters are passed as p1, p2, and so on, and separated by an ampersand (&).


Listing 5. URLs for GET methods of Universal Services

http://localhost:8888/servicesUniversalServices/rest/UniversalServices/getPrimaryKeys?

http://localhost:8888/servicesUniversalServices/rest/UniversalServices
    /getXMLDocumentByKey?p1=1

http://localhost:8888/servicesUniversalServices/rest/UniversalServices/deleteDocument?p1=3

http://localhost:8888/servicesUniversalServices/rest/UniversalServices
    /update?p1=<document4>updated document</document4>&p2=4

http://localhost:8888/servicesUniversalServices/rest/UniversalServices
    /insertXML?p1=A comment&p2=<document5>new doc</document5>

http://localhost:8888/servicesUniversalServices/rest/UniversalServices
    /runxpathXML?p1=.&p2=2



Back to top



Go to the previous pagePage 6 of 11 Go to the next page