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 3 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


Installing Universal Services

The DDL files in the included download bundle create the necessary objects in DB2, and the script create the .war file, which you can then deploy to the Web server.

The contents of the download bundle are shown in Figure 3:


Figure 3. Universal Services download bundle
Screenshot showing the file structure of the Universal Services download bundle

The only necessary configuration parameter is the location name of your DB2. You also, however, have the option to change the names of the DB2 objects creator, table, and columns as command line arguments.

The only .war component affected by customization is the config.xml file, which holds the SQL statements or operations supplied by the Web service, and for Tomcat, the context.xml file, which holds the data source definition. All the other files are included in the download bundle and added to the .war file unaltered.

The steps required for installation therefore include:

  • Create table and UDF in DB2
  • Configure script with table names and connection properties
  • Run script to generate .war file
  • Deploy .war file to Web server

Create objects in DB2

You need a table with the following columns:


Listing 1. Columns of table DB2ADMIN.SAMPLETABLE

ID              INTEGER GENERATED ALWAYS AS IDENTITY
COMMENT         VARCHAR(1000)
XMLDATA         XML

The names of the table and the columns are immaterial as long as the format is correct. Also, the table can contain additional columns; they just won't be referenced by Universal Services. If you do not have a table of your own that you want to use, the DDL for the table above is in the file createTable.txt.

The user-defined function is written in Java language. It takes as input an XPath expression, an ID, a table name, and column names, and returns the result of applying the XPath expression to an XML document, namely the one in the row of the table with the supplied ID.

A Java UDF consists of a Java load module and the DDL definition. The Java load module can either be installed into the DB2 catalog or into the Java directories in Unix System Services. This tutorial follows the recommended praxis of installing it into the DB2 catalog. To this end, this tutorial supplies a small Java technology program that calls the stored procedure SQLJ.DB2_INSTALL_JAR. You could also call the stored procedure from Data Studio.

To install the UDF, perform the following tasks:

  1. Modify supplied Java technology program uploadJar.java with the following information:
    • <hostname>, <port no>, and <location name> of the DB2 subsystem. This is the usual connection information needed when connecting to a DB2 subsystem.
    • <userid> and <password> for a user with the privileges needed to install a JAR into the DB2 catalog.
    • The path to the JAR file if Universal Services was not installed in the root directory of the C: drive.
  2. Compile and run the program:
    1. Start a command line in Windows.
    2. Navigate to the directory UniversalServicesZ.
    3. Enter the command javac uploadJar.java to compile.
    4. Enter the command java uploadJar to run.
  3. Create the user-defined function DB2ADMIN.XPATHXML:
    • Modify XPathDDL.txt. You must provide the name for the WLM environment used for Java routines in your environment. In the supplied DDL, it has the value DSN9WLMJ.
    • Run DDL in XPathDDL.txt, in, for example, SPUFI.


Back to top


Configure and generate .war file

You perform both the configuration and the generation by the script configure for zOS.bat. You perform the configuration by calling a Java program with the values for:

  • Table creator, table name, column names (these will be used in the SQL scripts for insert, update, delete, select, and query)
  • DB2 location name (this is used to define a connection if the Web server used is Tomcat)

The Java program generates the files config.xml and context.xml.

Afterwards, the Web archive is created by jar'ing these files with the other supplied files. The result is the file UniversalServices.war.



Back to top


Deploy to the Web server

The actual steps needed for deployment depends on which Web server is used. In each case, you need to:

  • Configure the data source (in other words, the connection to the DB2 subsystem where the data reside)
  • Deploy UniversalServices.war to the runtime environment of the Web server

Table 1 summarizes the information needed to configure the data source—regardless of which Web server is used. This information is needed whenever a remote connection is made to DB2 through DB2 Connect or a type 4 JDBC driver.

For illustration purposes, let's use the (non-existent) values DSN9 for <db2 name>, 9.123.45.678 for <host name>, 446 for <port no>, and db2admin for <userid>. You must supply your own values for your subsystem.


Table 1. Data source definition information
ElementDescription
<db2 name>The location name of your DB2 subsystem
<host name>The name of your z/OS system (could be a logical name or an IP-address)
<port no>Port number of the DB2 subsystem
<username>User id used for the connection
<pwd>Pwd for user id used for connection

The next section provides a detailed description of deployment with each of the Web servers.



Back to top



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