IBM Cloud Authors: Elizabeth White, William Schmarzo, Don MacVittie, Pat Romanski, Liz McMillan

Related Topics: IBM Cloud

IBM Cloud: Article

Building DB2-Based Web Services Using WebSphere: Part 1

Building DB2-Based Web Services Using WebSphere: Part 1

I've been involved with Web services for more than a year now. After the initial fascination and learning curve that are part of any new technology comes the part where you roll up your sleeves and start applying it for the sake of solving real problems or making architectural improvements to an existing system - as opposed to applying the technology for the sake of applying the technology.

I discovered early on that many real Web services applications involve database access. In many cases, Web services serve as an access layer, allowing functionality implemented in database management systems (whether through the use of SQL commands or through stored procedures) to be exposed and deployed for Web access. In such cases Web services act as wrappers to existing database-centric systems - wrappers that may be accessed over a SOAP or HTTP connection and that use XML to package inbound and outbound data. The pattern of Web services wrapping database operations stems from the fact that Web services make excellent wrappers and that many of the systems out there are database-centric.

Given that Web services are often used as wrappers for existing functionality, the main question is what should you be wrapping as a Web service. Normally the answer is a set of methods or functions deployed in the application server. My article "Developing Web Services with WebSphere Studio" (WSDJ, Vol.1, issue 4) showed how to use WebSphere Studio Application Developer to wrap an existing Java method as a Web service without writing a single line of code.

This month I'll introduce a technology that answers the question differently - one that allows you to quickly and easily wrap functionality within a DB2 database as a Web service. Because many production systems have evolved (or are in the process of evolving) from a client/server architecture to some form of three-tier architecture, the database server often encapsulates many of the business functions implemented in the system. In these cases, directly wrapping the database with Web services may be a simpler alternative that doesn't require you to first wrap database operations within Java methods and then create the Web services wrappers - instead, everything is done for you based on database operations and metadata.

Usage Scenario
Before delving into the technical details, let's look at a usage scenario taken from the world of call centers. Imagine a call center database in which all problem reports and work statuses are stored. 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 it. Work is encapsulated in an ACTION, which records information such as who's assigned to handle it, the scheduled start date, the estimated time of arrival (ETA), and so on. Information pertaining to what work was done in the context of an action is also recorded, and all this is maintained as a record in an ACTION table.

The CALL and ACTION tables are the heart of the service operation. Customer information systems need to access this data in case a customer calls and wants to know the status of an open problem; field engineers need to access it to get their work list for the day; managers need to run reports to track the number of open calls and how long it took to resolve problems; and financial systems need to access the action details to figure out whether the customer needs to be billed for the work. Some of these systems may even be located outside the enterprise. For example, it's possible that the field engineers work for an external service provider and use a separate system for work management. In this case, access to the central database is complicated by organizational boundaries, firewalls, permissions, and so on. It therefore makes sense to provide the API layer as a set of Web services.

The reasons for wrapping these APIs as Web services can be summarized as follows:
1.   The APIs need to be accessed by multiple decoupled systems, each created by a different vendor.
2.   Remote invocations may occur over the LAN or WAN. WAN access may include a third-party contractor managing an independent workforce, as well as wireless access from field units used when field engineers access their work list for the day. Figure 1 shows receipt of work orders though a Web-service interface delivered over a wireless network. The work orders communicated to the field include details on the scheduled start date, the work to be completed, and more. All this data is available within the CALL and ACTION tables, for example, the work order shown in Figure 1 (3975/1) is ACTION 1 in CALL 3975.
3.   Access to this data needs to come from multiple platforms. Each system may be written using a different programming language and running over a separate operating system. Because all modern platforms have added (or are adding) support for Web services, this makes it the only true interoperability technology today. This includes all platforms.

As an example, Microsoft recently released a new toolkit for Office XP that allows developers to consume Web services. It contains the Web reference tool for Visual Basic for Applications, which can be used to create proxy classes based on WSDL files. If you want to use Excel to display all call details for a certain customer, you can create a Visual Basic (VB) Web service proxy that invokes the APIs deployed on WebSphere Application Server (WAS) to access data stored in DB2 - all without writing a single line of code. Figure 2 shows an Excel spreadsheet with a push button used to call the VB stub that invokes the Web service and brings back the call information based on a customer name.

DB2 Web Services Wrappers
To make the discussion concrete, let's look at a small set of APIs to be delivered as Web services. (These Web ser-vices will be defined and implemented in my next article.) The operations to be wrapped as Web services are:

  • Given an employee ID, return a list
    of all work assigned to this resource.
  • Given a call number and an action number,
    return the status of the action and the
    because a call may have multiple actions).
  • Update the status of an action.
  • Retrieve all call details.
  • 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 cannot be
    phrased as an SQL operation and is implemented as a stored procedure.

These functions are based on two tables: the CALL table and the ACTION table. Some of the column names and descriptions are shown in Table 1.

Given these (partial) table structures, it's easy to implement the required functionality using simple SQL statements. As an example, the following SQL command returns a list of call/action numbers assigned to an employee with an ID of 112001:

select call__t, action_no
from action where action_status__c!='CLOSE'
and who_action__c='112001'

This returns a collection of 2-tuples, each with a call number and an action number:

3922 1
4006 1
3974 1
4037 1
3529 1
512 1
3975 1

This addresses the required functionality, but it's not exactly a Web service, is it? Here's where the magic starts. Using DB2, WAS, and a technology package called Web Services Object Runtime Framework (WORF), this can be immediately packaged as a Web service wrapper to be deployed on WAS accessing DB2.

WORF is a set of tools for implementing Web services with DB2. It is deployed on 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, including 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 (see Figure 3).

The DADX file used to build a Web service for the above query is shown in Listing 1. The file encapsulates the SQL used to implement the Web service functionality and allows for the employee ID to be passed in as an argument. To make this Web service available on your WebSphere server (assuming you have WORF and Apache SOAP 2.2), simply place this file under a subdirectory within the WEB-INF tree in the WORF-installed application directory (more on this in Part 2). That's it - your DB2 SQL command is now a Web service! You can invoke it using a SOAP request delivered to a URL of the form:


You can also invoke the service using an HTTP request of the form:

WORF allows you to take the investment you've made in your DB2 schema and procedures and immediately leverage it using Web services deployed on WAS. This first article of a two-part series explained the general framework of WORF and DADX and introduced you to a business scenario that illustrates this technology. Part 2 will continue with this scenario, including the technical details on how to build your DADX files, how to deploy them on WAS, and what other configuration settings are necessary to make your DB2 investment pay off as Web services.

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 his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
SYS-CON Events announced today that Evatronix 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. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things’). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing? IoT is not about the devices, it’s about the data consumed and generated. The devices are tools, mechanisms, conduits. In his session at Internet of Things at Cloud Expo | DXWor...