Testing Universal Services
Testing Universal Services
The Web service is accessed through the supplied test page.
The URL of the test page is
http://localhost:8080/UniversalServices/testServices.html,
depending on the port number of your Web server.
Figure 46 shows the test page (note that the port number 8888 is used
here):
Figure 46. Universal
Services test page
The operation getPrimaryKeys returns a list
of all the IDs of rows in the table. These can subsequently be used in
the other operations supplied, like delete,
update, or
query.
How to use the query operation
The query operation can be used for practice
with XPath expressions, or as a starting point for creating your own
dedicated XPath queries. You enter a native XPath expression (in other
words, without any DB2-specific keywords) in the text box. The
operation then wraps it in the necessary DB2 syntax before it is sent
to DB2 for processing. (This makes it easier to focus on the actual
XPath expression.)
The Universal Services are for use with any XML schema. This tutorial
therefore cannot supply many non-trivial examples that will work in
all cases. One that will work is '.', which
just returns the context node; that is, the whole XML document.
Another is '//text()', which prints all
text values in the document.
An example of an XPath expression for a UBL 2.0 Invoice document, which
simply selects the whole invoice, is shown in Listing 3:
Listing 3. XPath expression UBL 2.0 Invoice
declare default element namespace
"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2";
/Invoice |
For further information about and for the syntax of XPath, refer to the
tutorial
"Get Started with XPath"
(developerWorks, May 2004).
Industry Bundles
If you are interested in a specific XML format, or if you just need
some data for test purposes that have the quality of real-life data,
you may want to take a look at the Industry Bundles that are available
for download (see Resources > "Industry
Formats and Services with pureXML").
There are Industry Bundles for a number of different XML formats, such
as UNIFI, UBL 2.0, IRS1120, and more.
The bundles contain DDL for a table that matches the one this tutorial
uses for Universal Services. They also contain the XML schemas that
document the XML format and some sample XML documents adhering to this
schema. These can be used with Universal Services to test the
application.
|