You are on page 1of 19

Introduction

This document gives the step by step process for developing, deploying and testing of a
simple Webservice in RAD 6.0 IDE.

We can create the webservice in two ways

1) Bottom Up or Stub scenario : create a Web service from a Java bean or a EJB or a
DADX.
2) Top Down or Skeleton scenario : create a Web service from a Web Service
Description Language (WSDL) file

Depending upon the server and the chosen run-time, the artifacts that the Web services
wizard generates may vary. The end result is a deployed Web service on a server.

If a vendor deploys a Web service and you would like to create a client to use it, the
Web service client wizard does this by starting with the WSDL file.

A Web service can be based on a number of different types including a Java bean,
Enterprise Java Bean (EJB) component, DADX document, and so on..

Creating WebService From JavaBean

We can start at different points in the wizard and create a Web service using different file
types. One start point is with a Java Bean. The Web services wizard would then generate
the Requestor-side files including the proxy bean, the WSDL file, and Provider-side files.
This is known as the Bottom Up scenario

Bottom Up Web services scenario


Creating a Webservice From WSDL File

We can also start with a WSDL file and generate the Requestor-side artifacts and the
Provider artifacts including a skeleton bean with the WSDL operations. The
implementation is left to you to fill in. This is known as the Skeleton or Top Down
Scenario.

Top Down scenario

Web Service Deployment

When deploying a Web service, your choice of run-time and server affects both the
chosen J2EE specification level, as well as the files generated. WebSphere Application
Server V6.0 supports the J2EE 1.4 specification. The concept of Web projects being
deployed to an EAR file exists for WebSphere Application Server. Web services
information for J2EE is stored in a file called webservices.xml.

Suppose if we create a webproject named MyWSProject then the corresponding EAR


project is named MyWSProjectEAR.

If we are creating a webservice in Bottom Up scenario,In this case several file types
have been generated including deserializer, serializer, and helper files. These files
are used to convert the incoming XML message to Java language and outgoing Java
language to XML. There is also a SEI file which holds all the operations in the Web
service. The client proxy is generated using this file. A WSDL file is generated into the
Web Content directory. This contains information about the Web service that has just
been deployed to the server. The WSDL Test Clients use the WSDL file to test the
service directly. Rational Application Developer provides the Web service Explorer which
you can use to test the service.
Deploy the service to the EAR and deploy the EAR to the server

Deploying the Web services using the Web services wizard. A number of files are
generated to facilitate the serialization and deserialization of the messages to and from
the service. Information is also added to the webservices.xml, web.xml, and
x_mapping.xml. This information describes the deployment of the service. This follows
the J2EE 1.4 standard. At this point all the information about the Web service has been
deployed to the EAR. The EAR has then been added to WebSphere Application Server.

Generating the Client

To generate a client, select the checkbox next to the corresponding label that says
generate proxy on the first page of the Web services wizard. Another way to generate a
client is to start with a WSDL from the service. This is known as the Client scenario .In
this case it is assumed the service has already been deployed. The Web services wizard
creates a Web project called MyWSProjectClient and a new EAR file that contains this
project. Again there are serializer, deserializer, and helper classes. The key file that the
test facilities focus on is the proxy file.
Example of HelloWorld Web Service using Bottom-up approach

To create a new Dynamic Web Project in RAD6.0

Go to File->NewOther
Select Dynamic Web Project

Click Next, then enter the name of the Dynamic Web Project

Enter the project name as FirstWSproject


Click Next

Click Next
Click Finish and click Yes to open in J2EE perspective otherwise select No to open in
java perspective.
Now we can see two folders created in Package Exoplorer view,namely

FirstWSProject and FirstWSProjectEAR

To create a java class, go to FirstWSProjectjavaSourceNewClass


Give the package name as com.wu.firstws and give the class name as HelloWorld and
click Finish

Add a method sayHello() in the class HelloWorld.


To create a Web Service right click on HelloWorld.java class goto New->Other

Select Web Service in New Window. click Next


In the Web Services window check the check boxes as shown in below figure.

Click Next and browse HelloWorld.java file from that particular package structure
Click Next

Click Next
Click Next

Click Next
Click Next

Click Next it will take some time to generate the Client


Click Next

Click Finish and now WebServices Explorer window will be opened.


Click on sayHello() in the left panel where we can see the endpoint and the user defined
methods
Enter name in Inputs window against the name label in the text box.

Click on Invoke button. The result will be displayed in Result window.


The folder structure looks like the below.

A file HelloWorld_SEI.java is created in the same folder where HelloWorld.java resides.

A HelloWorld.wsdl is created in WEB-INF->wsdl folder which gives the details of the


webservice which is exposed like the name of the method, SEI, port etc.
Client folder structure looks like below.

HelloWorld, HelloWorldProxy, HelloWorldService, HelloWorldServiceInformation,


HelloWorldServiceLocator, HelloWorldSoapBindingStub are the files created in the client
project.

Some jsps are also created which can be used for testing the webservice.

You might also like