XQueryWebService is a framework that allows you to expose an XQuery as a Web service. In this section, you'll see how you can use DataDirect XQuery to build powerful data services that query, aggregate, and update multiple data sources using XQuery.
![]()
The application used to illustrate some of the features of the XQueryWebService framework is a simple employee lookup: based on the employee ID you enter, the query returns information such as first and last name, job level, date of hire, and so on.
Before getting started with the example presented in this section, you'll need the following:
Note: You need to use at least DataDirect XQuery 3.1 (build 034703). If you already have installed DataDirect XQuery but are using an earlier build, you can either:
You can use any Java servlet container you like; we used the open source Apache Tomcat for this example, so you will have to adjust references to Tomcat to the Java servlet container of your choice in your installation.
To get started with the XQueryWebService example:
<?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> <init-param> <param-name>QueriesFolder</param-name> <param-value>c:\MyQueryDir</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>
![]()
Once you've taken care of the basics, you're ready to move on, starting with specifying relational data sources, as described in the following section.
![]()