Welcome!

IBM Cloud Authors: Liz McMillan, Pat Romanski, Yeshim Deniz, Carmen Gonzalez, Elizabeth White

Related Topics: IBM Cloud

IBM Cloud: Article

Building DB2-Based Web Services Using WebSphere, Part 2

Building DB2-Based Web Services Using WebSphere, Part 2

In my previous article (WSDJ, Vol. 1, issue 7), I gave you a glimpse of the Web Services Object Runtime Framework (WORF), a set of tools for implementing Web services with DB2 and WebSphere. WORF is deployed on WebSphere Application Server (WAS) and uses Apache SOAP 2.2. It implements a layer that runs on WAS and is responsible for taking database access definitions and translating them on-the-fly to Web services constructs supporting SOAP messages and WSDL documents.

The mapping between the database definitions and the Web service is done in a Document Access Definition eXtension (DADX) file. WORF uses the DADX definition to provide an implementation of a Web service through a servlet that accepts a Web service invocation over SOAP, an HTTP GET, or an HTTP POST. This servlet implements the Web service by accessing DB2, invoking the SQL operation defined in the DADX file, and returning the results as a SOAP response.

Last month's focus was on the general framework and the reasons why DB2-based Web services are so attractive. This month I'll continue with a more in-depth discussion of WORF and show you how to build DADX files, deploy them on WAS, and more.

System Requirements and Installation
The system configuration required to implement DB2-based Web services through WORF includes the following:

  • DB2 Universal Database Version 7.2
  • DB2 XML Extender (only for advanced XML manipulation)
  • WebSphere Application Server version 4.0
  • Apache SOAP 2.2
  • WORF
Assuming you've already installed DB2 and WAS, the rest is simple and should take no more than five minutes. Installing SOAP 2.2 involves downloading the soap-bin-2.2.zip file (see Resources), unzipping it, and copying soap-2_2/lib/soap.jar into {WAS_HOME}/AppServer/lib.

Next, you need to install WORF. After you download worf.zip (see Resources), unzip it and copy worf.jar and soap-samples.jar to {WAS_ HOME}/AppServer/lib. You should then install the sample Web application services.war as a new enterprise application within WAS. You can do this using the administrator's console (regardless of whether you're running the single-server edition or the advanced edition). Figure 1 shows the first step of the installation using the single-server administrator's console. Remember, after creating the enterprise application you need to regenerate the Web server plug-in and restart the server. You're now ready to go.

Example Scenario
I'll continue using the example scenario from Part 1, which is taken from the world of call centers. In this example, a call center database stores problem reports and work statuses. For every problem called in by a customer, a CALL is created. The information describing the call is maintained in the CALL table. Once the call is logged, the support center starts working on the problem. Work is encapsulated in an ACTION, which records information such as who is assigned to handle the problem, the scheduled start date, the estimated time of arrival (ETA), and so on. Information pertaining to what work is done in the context of an action is also recorded, and all of this activity is maintained as a record in an ACTION table. The DADX files assume the table structures shown in Table 1.

The operations for which DB2-based Web services are provided are:

  • Given an employee ID, return a list of all work assigned to this resource.
  • Update the status of an action.
  • Given an employee ID, call a stored procedure that computes the yearly first-time fix rate (i.e., how frequently the engineer resolves the problem on his or her first attempt). This complex business function can't be phrased as an SQL operation and is implemented as a stored procedure.

    Building DADX Files
    At the heart of WORF are the DADX files, which specify how to create a Web service using SQL operations. DADX supports all SQL operations, including queries, updates, and calls to stored procedures.

    A DADX file is an XML document. The root node is a DADX node, but the real work is done within the operation nodes. Listing 1 shows a very simple DADX file defining a Web service called getWorkForEmployee, which receives an employee ID and returns a collection of two-tuples, each containing the call number and the action number.

    DADX also supports update operations. As an example, Listing 2 shows the DADX file used for the second Web service on our list - a Web service that updates the status of a call. The operation in this DADX file is an update operation that wraps an SQL update statement. Note that in addition to the operation, a documentation element has been added; this will find its way into the WSDL file that's automatically generated by WORF on your behalf. Finally, Listing 3 shows the DADX document for the third Web service wrapping a call to a stored procedure. Incidentally, a DADX file may contain many operation elements, each transformed into a Web service by WORF.

    Deploying and Calling WORF Web Services
    You need to do a bit of setup before you can start accessing your DADX-based Web services. Specifically, you need to set up a WORF group and specify the database properties that will be used to access the database. After all, the DADX files define the SQL commands but don't specify the database instance to which the SQL should be applied.

    Database properties are specified within a groups.properties file, as shown in Listing 4. This file tells WAS which JDBC driver to load and how to connect to the database. It also defines reload parameters allowing you to modify the DADX files and have WAS reload the definitions automatically. In our example, the groups.properties should be placed in a folder called callWS under {WAS_HOME}/App Server/installedApps/servicesApp.ear/WEB-INF/classes/groups. Your DADX files should also be placed here.

    You need to inform the WORF that you've created a new group and the associated Web services. For each group, add a DxxInvoker servlet to your web.xml file within the Web application. Each invoker servlet handles a set of Web services that access the same DB2 instance. Listing 5 shows the additions to the web.xml file required to support the CALL Web services; now you're ready to start using the Web services.

    WORF supports both HTTP bindings and a SOAP binding. When invoking a WORF Web service using an HTTP GET binding, use a URL of the form http:// <host>/callWS/getWorkForEmployee.dadx/getWorkForEmployee?employee_id=112001. This invokes the first operation shown in Listing 1, passing in the employee ID to be used by the SQL query. The same form of invocation would be used in an HTTP POST request, except that the parameter would be passed within the request body.

    To use the SOAP binding, activate a URL of the form http://<host>/ call WS/getWorkForEmployee.dadx/SOAP. The input arguments are passed in as a SOAP request within the body of the request. If all operations are packaged together in a single DADX file (let's assume all operations are inside the CALL.dadx file), the invocation over HTTP GET would take the form of http://<host>/callWS/ CALL.dadx/ getWorkForEmployee?employee_id=112001. Invocation over SOAP would always use a URL of the form http://<host>/callWS/ CALL.dadx/ SOAP, while the SOAP request would embody the actual operation that needs to be invoked.

    WSDL and Schema Files
    WORF is used not only at runtime for wrapping the SQL operation as a Web service in the context of an invocation; it also generates all that's required to deploy your Web service. WORF can automatically generate a Web Services Description Language (WSDL) file, which allows others to learn how to use your Web service. You can publish this WSDL document in a UDDI registry.

    For example, to get the WSDL file for the query shown in Listing 1, simply access a URL of the form http:// <host>/callWS/getWorkForEmployee.dadx/WSDL. This will return a WSDL document that describes your Web service. If you want to publish your Web service on a UDDI registry, you actually need the WSDL delivered in two files - a service file and a binding file. To retrieve these documents use the following two URLs:

    http://<host>/callWS/getWorkForEmployee.dadx/WSDLservice
    http://<host>/callWS/getWorkForEmployee.dadx/WSDLbinding

    WORF even takes care of generating schema files for you. Regardless of whether you use advanced XML manipulation with the XML Extender (in which case metadata is often held as DTDs), you can easily retrieve XSD files for your Web service. As an example, to generate an XSD file for the getWorkForEmployee Web service simply access a URL of the form http://<host>/callWS/getWorkForEmployee.dadx/XSD.

    Advanced XML Manipulation
    WORF supports two types of Web services: SQL-based operations and XML-based operations. The DADX documents shown above have all been SQL-based operations. XML-based operations allow you to compose XML documents from relational data and store it. You can create as complex a mapping as is required to allow you to make the most of your relational store without compromising your XML layouts. This uses advanced XML collection operations supported by the DB2 XML Extender, a package that allows you to store and retrieve XML documents from DB2 using flexible metadata definitions. To use these advanced features you must have the DB2 XML Extender option installed, and you need a more thorough understanding of how to use DAD files. This requires a bit of learning; for more details, see the Resources section.

    Summary
    WORF allows you to Web service-enable your DB2 database and leverage your investment in the database schema and its procedures by autowrapping them with Web services deployed on WAS. You can do this easily by writing a simple DADX file and inserting it into an appropriate groups directory.

    Because so many of today's systems are database-centric, many of the Web services you may need to build involve either database operations or storing/retrieving data from your data store. I hope that when you have such a task you remember WORF and the work it can save you. While this two-part series introduced you to the subject, it is by no means a complete overview of WORF, XML Extender, DADX, or DAD files. The resources below provide all you need to build and deploy DB2-based Web services.

    Resources

  • Download DB2 v7.2 at www14.software.ibm.com/webapp/download/ category.jsp?s=c&cat=data .
  • Download XML Extender for DB2 at www-3.ibm.com/software/data/db2/extenders/ xmlext/downloads.html.
  • Download a trial version of WAS 4 at www7b.boulder.ibm.com//wsdd/downloads/#WAS.
  • Download Apache SOAP 2.2. at http://xml.apache.org/dist/soap/version-2.2.
  • For more information and to download WORF, see www-3.ibm.com/software/data/db2/extenders/ xmlext/docs/v72wrk/WORF.html.
  • For more information on XML Extender and DAD files, see ftp://ftp.software.ibm.com/ps/products/ db2/info/vr7/pdf/letter/db2sxe70.pdf.
  • For more details on DADX, download the DADX specification at ftp://ftp.software.ibm.com/ps/products/db2extenders/ software/xmlext/docs/v72wrk/webserv/dadx.html.
  • More Stories By Ron Ben-Natan

    Ron Ben-Natan is Chief Technology Officer at ViryaNet Inc. Prior to that he worked for companies such as Intel, AT&T Bell Laboratories, Merrill Lynch and as a consultant at J.P. Morgan. He has a Ph.D. in Computer Science in the field of distributed computing and has been architecting and developing distributed applications for over 15 years. His hobby is writing about how technology is used to solve real problems and he has authored numerous books including “IBM WebSphere Application Server: The Complete Reference” published by Osborne/McGraw. He can be reached at

    More Stories By Doron Sherman

    Doron Sherman is the CTO of Collaxa, Inc., a Web Service Orchestration Server vendor and a BEA Partner located in Redwood Shores, California. He has been involved with Java since its early days and pioneered application server technology while being a founder and chief scientist at NetDynamics.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    @ThingsExpo Stories
    In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
    SYS-CON Events announced today that CAST Software will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CAST was founded more than 25 years ago to make the invisible visible. Built around the idea that even the best analytics on the market still leave blind spots for technical teams looking to deliver better software and prevent outages, CAST provides the software intelligence that matter ...
    SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
    As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...
    SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
    SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
    SYS-CON Events announced today that SourceForge has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. SourceForge is the largest, most trusted destination for Open Source Software development, collaboration, discovery and download on the web serving over 32 million viewers, 150 million downloads and over 460,000 active development projects each and every month.
    SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...
    Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
    SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
    Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
    SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
    SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
    SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
    SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
    Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
    SYS-CON Events announced today that TidalScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
    As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
    Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
    As popularity of the smart home is growing and continues to go mainstream, technological factors play a greater role. The IoT protocol houses the interoperability battery consumption, security, and configuration of a smart home device, and it can be difficult for companies to choose the right kind for their product. For both DIY and professionally installed smart homes, developers need to consider each of these elements for their product to be successful in the market and current smart homes.