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 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:

http://<host>/services/samples/
getWorkForEmployee.dadx/SOAP

You can also invoke the service using an HTTP request of the form:
http://<host>/services/samples/
getWorkForEmployee.dadx/getWorkForEmployee?
employee_id=112001

Summary
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
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.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...