The architecture of Universal Services
The architecture of this small application is three-tier, as shown in Figure 1. At the back end, DB2 for z/OS acts as a database server. The application layer in this case is a Web server running on Windows. The presentation layer or user interface is the Web page itself.
Neither layer is very complex. This tutorial discusses them briefly to give a basic understanding of the different elements and how they work together, although it is not strictly necessary to understand the inner workings of the Web services to set up the Universal Services.
In DB2, there is a single table with three columns: ID, which has type INT; COMMENT, which has type VARCHAR; and XMLDATA, which is an XML column. This table is used to store all the XML data for the application, which is just a collection of individual XML documents, each identified by an ID key and with an optional comment field.
There is also a user-defined function that takes an XPath expression and an XML document as input and returns the result of applying this XPath expression to the XML document.
This tutorial uses either WebSphere Application Server, WebSphere Application Server Community Edition, or Tomcat running on Windows (for example, your own laptop) as the Web server. The actual Web service is a set of operations built from simple SQL scripts for select, insert, update, and delete, as well as a script calling the user-defined function defined in DB2 with an XPath expression received through the Web page.
The individual Web service operations are invoked through a Java Servlet, which is supplied together with some necessary libraries.
Together with a few files containing definitions and mappings between different elements, these files comprise the application layer.
The user interface is written in XHTML with XSL stylesheets to format
the output from two of the operations of the Web service, namely
getXMLDocumentByKey (the select operation)
runxpathXML (the query operation).
Figure 1 illustrates the architecture of Universal Services:
Figure 1. Architecture of Universal Services
For WebSphere Application Server Community Edition and Tomcat, this tutorial uses the REST protocol, which is really just a fancy way of saying that you send XML over HTTP. For WebSphere Application Server, this tutorial uses SOAP, where (among other things) the messages are wrapped in XML envelopes containing various metadata.
This tutorial accesses DB2 on z/OS from Windows using a JDBC type 4 driver.
The application layer and the presentation layer are packed together in a .war file, which is deployed to the Web server. The .war file is an archive that contains the following:
- JAR files containing the Java Servlets that interpret the Web service operations and some library classes needed by the servlets
- WSDL file containing a definition of the Web service (in other words, the operations, their arguments, their protocol binding, and their physical location)
- XML files containing relationships between the different components: web.xml mapping URLs to servlets, config.xml mapping operations to SQL statements, and other platform-specific XML files
- XHTML file containing the definition of the Web page
- XSL files containing stylesheets for formatting the results from two of the five operations of the Web service (the remaining three are so simple, they don't need them)
Figure 2 illustrates the folder structure of the .war file:
Figure 2. .war file structure