Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

DB2

Posted Nov 17, 2008

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

By Paul Zikopoulos

Building your first Web service

To transform the FEMALEPERSONNEL SQL statement into a Web service, perform the following steps:

1.  Right-click the Web Services folder in the DatabaseJournalProject data development project, and select New Web Service.

select New Web Service

2.  The New Web Service wizard opens. Type a name for the Web service in the Name field, and then click Finish. For this example, use SOA_FEMALEPERSONNEL, as shown below:

The New Web Service wizard opens

Since this Web service was created from an existing data development project, the Project field is automatically filled in for you. If you click the drop-down list for this field, you can select to create your Web service in any existing project and its associated database connection.

you can select to create your Web service in any existing project

This is a very useful feature if you want to deploy the Web service to a myriad of target data servers. For example, perhaps your development environment is based on DB2 for Linux, but you want to deploy the service-built application to a DB2 for z/OS data server. This feature streamlines the deployment process; you can build and test in a Linux environment and deploy to the DB2 for z/OS data server.

You can also use this wizard to create a new data development project and link it to a different target IBM data server. Click New and follow the steps in the Data Development Project wizard that you were introduced to at the start of this series.

The Data Project Explorer view should now look like this:

The Data Project Explorer view

3.  Select the FEMALEPERSONNEL SQL statement and drag it onto the SOA_FEMALEPERSONNEL folder:

Select the FEMALEPERSONNEL SQL statement

You should see that the selected SQL statement has been added to the SOA_FEMALEPERSONNEL Web services project, located in the Web Services folder.

If the logic you want to expose as a Web service doesn’t currently exist in your database or data development project, you can define the logic for the Web service as you define it. Right-click the Web service that you are creating, and select New Operation:

Right-click the Web service that you are creating, and select New Operation

You get the content assist and syntax colorization features of the SQL Editor (introduced earlier in this series in part 7) when you define business logic inline. I recommend that you always create a separate SQL statement to add to a Web service. Doing this gives you a lot more options to reuse and tune the SQL statement since it persists outside of the Web service as its own artifact in a data development project. What’s more, using this method gives you access to any of the wizards that assist you in building a routine.

4.  Perform the following steps to create a link to an application server where the Web service will be deployed:

a.  Select the Servers tab, right-click anywhere in the tab’s white space, and select New>Server. The New Server window opens.

b. Select the appropriate application server. For this series, assuming you are using IBM Data Studio V1.2, select WebSphere Application Server Community Edition v1.1 Server, and click Next.

Select the appropriate application server

I selected WebSphere Application Server Community Edition v1.1 Server because I’m using IBM Data Studio Version 1.2. For IBM Data Studio V1.0, you would use WebSphere Application Server Community Edition v1.0 Server. You can also see that I’ve got Apache Tomcat installed on my machine as well; I could choose to deploy the Web service to this application server too (or a number of others which aren’t installed on my system).

Note: This article assumes that you are defining a link to a WebSphere Application Server/CE application that resides locally on your workstation (the same one where the SAMPLE database was created). When creating Web services with DB2 data servers, you don’t need to manually configure the target application server for use with IBM DWS; it’s done automatically for you. If you’re using DB2 for z/OS, DB2 for i, or an Informix Dynamic Server data server, you must register the data server JAR files on the application server. Refer to the IBM Data Studio help for more information.



DB2 Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 



















Thanks for your registration, follow us on our social networks to keep up-to-date