DBA > Articles

Transforming Business Logic into Web Services Using DB2 9.5 and IBM Data Studio

By: Paul Zikopoulos
To read more DBA articles, visit http://dba.fyicenter.com/article/

In the first ten parts of this series, Iíve introduced you to some of the many features available within the IBM Data Studio integrated development environment (IDE), which can be used with any of the mainstream relational IBM data servers. Specifically, Iíve shown you how to set up and use database connection objects, how to generate an overview diagram of your database architecture, how to build OLE DB functions that can be used to easily integrate data from external data sources that have an OLE DB provider, and how to create an SQL statement using either the SQL Builder or the SQL Editor in IBM Data Studio. Finally, I showed you how to take the FEMALEPERSONNEL SQL statement built in previous installments and quickly turn that into a stored procedure using the New Stored Procedure wizard in IBM Data Studio.

In this part, Iím going to show you how to take business logic such as stored procedures, functions, or SQL statements (often referred to as routines) and turn them into a Web service.

An introduction to IBM Data Web Services
If you open any magazine, surf any Web site, or attend any conference, youíd be hard-pressed to avoid hearing or reading about Web services. Theyíve been around for some time now and are used to create loosely coupled applications. The specifications and standards associated with Web services such as SOAP and the Web Services Description Language (WSDL) are well defined and mature. As companies move their IT applications towards service-oriented architecture (SOA), there is often a need to expose underlying application functionality and business logic stored within a data server as a Web service (for example, the SQL statement and stored procedure created so far in this series). While Web service enablement itself is not equal to SOA, Web services are vital components towards making SOA possible.

IBM Data Web Services (IBM DWS) is a technology that revolutionizes the way you can expose database business logic as services for use in SOA applications. Using IBM DWS with IBM data servers, you can easily provision encapsulated business logic such as SQL scripts and routines as Web services with mere clicks of a button. Thatís right; you can literally take any SQL statement or routine, right-click, and generate invocations for JMS, SOAP, or REST Web service end points, which can then be used in building loosely coupled applications. Furthermore, you can group multiple database operations into one or more services that can be deployed and run on a myriad of supported application servers and invoked by any client with a Web browser.

To appreciate just how much IBM DWS simplifies your path to SOA applications, you need to understand why the IBM DWS technology was invented, and what creating a Web service was like using previous versions of DB2 software.

One major problem in the large-scale adoption of DB2 Web services and the migration of legacy applications to these services has been the lack of a good foundation and toolset to quickly create and provision them. For example, earlier versions of DB2 software used the WebSphere Object Runtime Framework (WORF) to enable service operations on top of DB2. Although WORF does the job, the effort that went into the definition and development of these Web services was cumbersome; specifically, it involved creating custom Data Access Definition Extension (DADX) files, which were complex and not based on any standards. In addition, the WORF framework was specific to the DB2 family of products and wasnít well supported for other IBM data servers such as Informix Dynamic Server.

IBM DWS was introduced when DB2 9.5 became generally available. You might have noticed that this Web service infrastructure is aptly named IBM Data Web Services. Thereís no DB2 in that title; thatís because this technology can be used across of all the mainstream IBM data servers: DB2 for Linux, UNIX, and Windows, DB2 for z/OS, Informix Dynamic Server, and DB2 for IBM i (formerly known as IBM i5/OS). Whatís more, itís applicable to back-level versions of these data servers too! For example, you can expose business logic on a DB2 Universal Database Version 8.2 for Windows database as a Web service using this framework.

The best part about the IBM DWS technology (as youíre going to find out) is that it provides a framework to transform business logic into a Web service without writing a single line of code! The IBM DWS technology is fully integrated into IBM Data Studio, which makes it easy to create bottom-up Web service development (auto WSDL generation, XML mapping, type mapping, and so on).

Specifically, IBM DWS provides the following features for IBM data servers:
* Single-click creation capabilities that include a drag-and-drop deployment infrastructure (thereís a new folder for Web services in IBM Data Studio) without any programming
* Full Web service interface support such as SOAP over HTTP, automatic WSDL generation, and more
* REST-style service interface with HTTP GET/POST bindings
* Web 2.0 capabilities (for example, JSON, RSS, Feeds, AJAX with XSLT, and so on)
* The capability to expose legacy application components as services

The path to Web services starts and ends in IBM Data Studio. For example, using IBM Data Studio you first create a data development project, which acts as a container for the Web services work youíre going to create, such as SQL scripts, routines, Web services, and XML artifacts, as youíve done thus far in this series.

Each data development project is linked to a database connection involving any of the following IBM data servers: DB2 for Linux, UNIX, and Windows (Version 8 or later), DB2 for z/OS (Version 7 or later), DB2 for i (Version 5 or later), and Informix Dynamic Server (Version 10 or later).

You can optionally deploy your Web services to a myriad of provisioning tiers. For example, WebSphere Application Server Community Edition (Application Server/CE) is included as part of an IBM Data Studio download. IBM DWS can also be deployed through IBM Data Studio to other popular application servers such as IBM WebSphere Application Server, Apache Tomcat, and even the IBM Data Power SOA Appliance. IBM Data Studio also gives you the option to generate a Web Archive (WAR) file for deployment to Web teams.

IBM DWS supports SOAP, JMS, and REST end points for Web services. The variety of end points and supported styles offers plenty of options in terms of clients that can be used to invoke these services. When you create a Web service in IBM Data Studio, the default selection is to generate SOAP and REST services; while deploying your Web services, you can select which services to generate according to your application requirements. If you generate SOAP/HTTP style services, the XML request document is contained inside the SOAP body element of the SOAP request message. The IBM DWS REST style interface supports the following request types: HTTP POST with an XML request document, HTTP GET with input parameters in a URL, and HTTP POST with URL-encoded parameters in the request document. IBM Data Studio also provides XSLT features that you can use to apply style sheet transformations to each service operation; youíd use this option to customize both input and output streams to and from the service. For example, you can have the output of a service delivered to your client in XML, and use an XSLT transform to fine-tune the display results to match the clientís form factor. The ability to define XSLT transformations in IBM Data Studio for your Web services is very useful for a wide array of applications beyond formatting. For example, you can use it to customize your Web service to conform to an existing WSDL document. The retrieved XML format from IBM DWS might not be the desired one for your other applications; the right format depends on the application or existing IT infrastructure and the nature of the project. XSLT can be used to map both input and output of DWS to existing XML schema specifications.

Whatís more, you no longer need to choose between top-down or bottom-up approaches to building Web services since the bottom-up services generated by IBM DWS can be mapped to the top-down format requirements on the client. You can also use this feature to retrieve results in formats such as JSON, or generate feed formats such as RSS, based on the database content.

Finally, IBM DWS comes with a number of testing tools that you can use to quickly perform sanity and quality assurance testing for your Web services. At this point, weíve spent enough time talking about IBM DWS; itís time to start using it.

Full article...

Other Related Articles

... to read more DBA articles, visit http://dba.fyicenter.com/article/