Before you start
This tutorial is for developers who want to learn how to use and combine Web services from the XML point of view, and to output that data to the Web. It assumes that you are familiar with Java™, XML, SQL, Web development and the basic concepts of Web services. Familiarity with JDBC will be helpful. If you need a refresher for these topics, please check out the Resources for more information.
It seems you can't turn around on the Web these days without running into a Web site that either offers access to its data through a Web-services-based API or uses data from another site obtained through a Web-services-based API. When you consider the advantage of using existing information in your own applications, that's probably not terribly surprising. It was also just a matter of time before someone started to combine the data from these disparate systems to create something entirely new. These applications, called mashups, are the latest rage on the Web, from community-based sites to specialized search sites to the ever-present mapping mashups.
They're (almost) all useful, but one thing that they have in common is that they were all developed for a specific set of services. If one of those services changes, or if the preference for a specific service of a particular type changes, you'll have lots of work to do.
The purpose of this tutorial series is to create a mashup application so smart that users can literally add and remove services at will, and the system will know what to do with them. The series progresses as follows:
In Part 1, Nicholas Chase introduced the concept of mashups, showed how they work and led you through how to build a simple version of one (see Resources). You also discovered some serious performance problems involved in making potentially dozens of Web calls.
In this tutorial, Part 2, you solve some of that problem by using new pureXML™ of IBM® DB2® capabilities to build an XML cache, which saves the results of previous requests and also enables you to retrieve specific information.
Ultimately, you will need to use ontologies, or vocabularies that define concepts and their relationships, so in Part 3 you start that process by learning about RDF and RDFS, two key ingredients in the Web Ontology Language (OWL), which we discuss in Part 4. In Part 5, we take the ontologies you created in Part 4 and use them to enable users to change out information sources.
In Part 6, the fun increases. At this point, you have a working application and the framework in place so that the system can use semantic reasoning to understand the services at its disposal. In this part, you give the user control, enabling him or her to map new services into the ontology and to pick and choose the data that is used for a custom mashup.
This tutorial is Part 2 in a six-part series about how to use and combine Web services from an XML point of view and output that data to the Web. In Part 1, you learned about collecting XML from services using REST services, but the concepts are the same for SOAP services (see Resources). You will continue this series by storing that XML data into a database creating a cache of the query results. Additionally you will retrieve that data for use in your Java application.
Over the course of this tutorial, you will learn how to set up a database server and prepare it to receive the data that you collect as well as how to write the queries needed to specifically handle XML data in an XML column.
You will learn to:
- Set up DB2 Enterprise Edition
- Create a new DB2 9 database which is configured to handle XML
- Create a database table using the XML column type
- Select information stored as XML in a relational database using XPath
- Write XQuery XML queries
- Write hybrid SQL and XQuery queries
This tutorial uses Java, but the concepts are the same for any programming language or operating system.
To follow along with the code in this tutorial, you will need to install and test the following software:
- IBM® DB2® 9 (formerly known as "Viper"): This relational database also includes significant XML capabilities, which you'll need for this tutorial. You can download a trial version of DB2 9: DB2 Enterprise 9 or DB2 Express-C 9, a no-charge version of DB2 Express 9 data server.
- Apache Tomcat or other servlet engine: This tutorial assumes that you will build Web applications using servlets, so you'll need a servlet engine such as Apache Tomcat. If you choose to build the application using another environment, just make sure you have the appropriate software on hand. Download apache-tomcat-5.5.17.zip and install into a directory with no spaces in the directory name.
- Java: Apache Tomcat 5.5, with which this tutorial is built, requires Java 1.5 or higher. Download the J2SE SDK.
- To make things easier, you can use an IDE such as Eclipse or IBM Rational™ Web Developer for your development. You can download Eclipse at Eclipse.org, download a trial version of Rational Web Developer, or use your favorite development environment. You won't do anything fancy as far as compilation and deployment are concerned.




