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
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:
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.
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:
3. Select the FEMALEPERSONNEL
SQL statement and drag it onto the SOA_FEMALEPERSONNEL folder:
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 doesnt 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:
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. Whats more, using
this method gives you access to any of the wizards that assist you in building
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 tabs white space, and select New>Server.
The New Server window opens.
I selected WebSphere
Application Server Community Edition v1.1Server because Im 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
Ive 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 arent 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 dont need to
manually configure the target application server for use with IBM DWS; its done automatically for you. If youre 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.
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.