Example – Employee Lookup


The application described in the following sections is a simple employee lookup query designed to illustrate some of the features of the XQueryWebService framework. When complete, the query returns information such as first and last name, job level, date of hire, and so on based on the employee ID you enter.

Other Examples

You can find other examples of the XQueryWebService framework on the DataDirect XQuery web site, here:

http://www.datadirect.com/developer/data-integration/tutorials/examples/xquerywebservice/index.ssp

Before You Begin

If you want to run the employee lookup example, you need the following:

You can use any Java servlet container you like; we used the open source Apache Tomcat for this example. If you plan to run the example on a different servlet container, you will need to follow its specific deployment procedure.

Setting Up

Once you have your XQuery editor and Java servlet container, you can set up the files needed to write your own employee lookup XQueryWebService framework application. Here’s how to get started:

  1. Copy the all DataDirect XQuery jar files to your Java servlet container \lib directory (<Tomcat_dir>\lib, for example). The jar files are located in the \lib directory where you install DataDirect XQuery.
  2. Create an employee-lookup directory under the Java servlet container \webapps directory (<Tomcat_dir>\webapps\employee-lookup, for example).
  3. Create a WEB-INF directory under the newly created \employee-lookup directory (<Tomcat_dir>\webapps\employee-lookup\WEB-INF, for example).
  4. Create the following configuration file as web.xml and save it to the WEB-INF directory:
<?xml version="1.0"?> 
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/ 
             j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
         version="2.4"> 
 
    <description>Employee lookup</description> 
    <display-name>Employee-lookup</display-name> 
 
    <servlet> 
        <servlet-name>XQueryWebService</servlet-name> 
        <servlet-class>com.ddtek.xquery.webservice.XQServlet</servlet-class> 
        <init-param> 
            <param-name>JNDIDataSourceName</param-name> 
            <param-value>jdbc/employee-lookup</param-value> 
        </init-param> 
    </servlet> 
 
    <resource-ref> 
        <res-ref-name>jdbc/employee-lookup</res-ref-name> 
        <res-type>javax.sql.DataSource</res-type> 
        <res-auth>Container</res-auth> 
    </resource-ref> 
 
    <servlet-mapping> 
        <servlet-name>XQueryWebService</servlet-name> 
        <url-pattern>/*</url-pattern> 
    </servlet-mapping> 
</web-app>  

Next Steps

Once you have taken care of the basics, you can begin specifying relational data sources, as described in the following section.