You are on page 1of 38

Developing Web Service using RAD 7.5 for WAS 6.

Developing Web Service using RAD 7.5 for WAS 6.1


Status: <Draft version >

Version:
TCS Confidential

2.1

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Version number
Date
Status
Author

Last save on

Page

17/11/2014

2/38

Version
2.1

Re visio n : : 1 .0
Date:: 17 november 2014
Draft
Anirban Ganguly

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

3/38

Version
2.1

Contributors
The following persons contributed to this document:
Name
Anirban Ganguly

External/Internal Review
This document requires the following External/Internal Reviews. Records of the appropriate reviews are filed
in the Quality section of the project control documentation.
Name
Raghu Warrier
Naga Polavarapu

Function
TCS SME (Internet Banking)
TCS SME (Internet Banking)

Document Reference Information


Version history
Nr

Date

Remarks / Changes

Status
Draftt

Web Service using RAD 7.5

Author

Approved

Template Version: 1.0

Subject

Last save on

Page

17/11/2014

4/38

Developing Web Service using RAD 7.5 for WAS 6.1

Version
2.1

TABLE OF CONTENTS
1
2

INTRODUCTION....................................................................................................................................... 5
WEB SERVICES....................................................................................................................................... 6
2.1
DEVELOPMENT APPROACHES................................................................................................................................6
2.2
TECHNOLOGIES USED...........................................................................................................................................6
2.3
CONSUMER SERVICE (CLIENT)..............................................................................................................................7
2.4
TESTING TOOLS.....................................................................................................................................................7
WEB SERVICE USING RAD 7.5 (JAX RPC, SOAP 1.1)...........................................................................8
3.1
SCOPE OF THE PROOF OF CONCEPT......................................................................................................................8
3.2
CREATING WEB SERVICES FROM A JAVA BEAN....................................................................................................9
3.3
GENERATED FILES IN WEB SERVICE...................................................................................................................15
GENERATING THE WEB SERVICE CONSUMER (SOAP 1.1)..............................................................17
4.1
TEST APPROACH 1: TEST WITH WEB SERVICES EXPLORER................................................................................17
4.2
TEST APPROACH 2: GENERATE CLIENT AND SAMPLE JSP.................................................................................20
4.3
VIEW IN TCP IP MONITOR..................................................................................................................................24
WEB SERVICE USING RAD 7.5 (JAX WS 2.0, SOAP 1.2)....................................................................26
5.1
SERVER SIDE GENERATED CODE........................................................................................................................30
5.2
GENERATED WSDL............................................................................................................................................30
5.2.1
WSDL (EmployeeInfoService.wsdl) with SOAP 1.2 specifications............................................................30
5.2.2
WSDL (EmployeeInfo.wsdl) with SOAP 1.1 specifications........................................................................30
5.2.3
SOAP Request Response............................................................................................................................31
CONCLUSION......................................................................................................................................... 34

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

5/38

Version
2.1

1 INTRODUCTION
Web services are self-contained software services that can be accessed using simple protocols over a
network. They can also be described using standard mechanisms, and these descriptions can be published
and located using standard registries. Web services can perform a wide variety of tasks, ranging from simple
request-reply to full business process interactions. Using tools like Rational Application Developer (RAD),
existing resources can be exposed as Web services very easily.

Web services in J2EE V1.4


One of the main changes in moving from J2EE V1.3 to V1.4 is the incorporation of Web services into the
platform standard. J2EE V1.4 provides support for Web services clients and also allows Web services to be
published. The main technologies in J2EE V1.4 that provide this support are as follows:
Java API for XML-based Remote Procedure Calls (JAX-RPC): JAX-RPC provides an API for Web
services clients to invoke services using SOAP over HTTP. It also defines standard mappings between
Java classes and XML types.
SOAP with Attachments API for Java (SAAJ): Allows SOAP messages to be manipulated from within
Java code. The API includes classes to represent such concepts as SOAP envelopes (the basic
packaging mechanism within SOAP), SOAP faults (the SOAP equivalent of Java exceptions), SOAP
connections, and attachments to SOAP messages.
Web Services for J2EE: This specification deals with the deployment of Web Service clients and Web
services themselves. Under this specification, Web services can be implemented using JavaBeans or
stateless session EJB s.
Java API for XML Registries (JAXR): This API deals with accessing XML registry servers, such as
servers providing UDDI functionality.
The specifications for Web services support in J2EE V1.4 are available at:
http://java.sun.com/j2ee/

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

6/38

Version
2.1

2 WEB SERVICES
2.1

Development Approaches

There are two general approaches to Web service development: top-down and bottom-up.
In the top-down approach, a Web service is based on the Web service interface and XML types, defined in
Web Services Description Language (WSDL) and XML Schema Definition (XSD) files. The developer first
designs the implementation of the Web service by creating a WSDL file using the WSDL editor. The
developer can then use the Web services wizard to create the Web service and skeleton Java classes to
which the developer can add the required code. The developer then modifies the skeleton implementation to
interface with the business logic.
In the bottom-up approach, a Web service is created based on the existing business logic in Java beans or
EJB s. A WSDL file is generated to describe the resulting Web service interface. The bottom-up pattern is
often used for exposing existing function as a Web service. It might be faster, and no XSD or WSDL design
skills are needed. However, if complex objects (for example, Java collection types) are used, then the
resulting WSDL might be hard to understand and less interoperable.
The top-down approach allows for more control over the Web service interface and the XML types used, and
is the recommended approach for developing new Web services.
Rational Application Developer provides wizards for exposing a variety of resources as Web services. In this
document we will describe the process to
create a new web service from a simple Java Bean.
The Web Service wizard assists us in creating a new Web Service from a simple Java class, configures it for
deployment, and deploys the Web Service to a server. The server can be the WebSphere Application
Server V6.1 Test Environment included with Rational Application Developer or another application server.

2.2

Technologies Used

The following core technologies are used for Web services:

XML
Extensible Markup Language (XML) is the markup language that underlies Web services. XML is a generic
language that can be used to describe any kind of content in a structured way, separated from its
presentation to a specific device. All elements of Web services use XML extensively, including XML
namespaces and XML schemas.
The specification for XML is available at:
http://www.w3.org/XML/

SOAP
Simple Object Access Protocol (SOAP) is a network, transport, and programming language neutral protocol
that allow a client to call a remote service. The message format is XML. SOAP is used for all communication
between the service requester and the service provider. The format of the individual SOAP messages
depends on the specific details of the service being used.
The specification for SOAP is available at:
http://www.w3.org/TR/soap/

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

7/38

Version
2.1

WSDL
Web Services Description Language (WSDL) is an XML-based interface and implementation description
language. The service provider uses a WSDL document in order to specify:
operations a Web service provides
parameters and data types of these operations
service access information
WSDL is one way to make service interface and implementation information available in a UDDI registry. A
server can use a WSDL document to deploy a Web Service. A service requester can use a WSDL document
to work out how to access a Web Service (or a tool can be used for this purpose).
The specification for WSDL is available at:
http://www.w3.org/TR/wsdl/

2.3

Consumer Service (Client)

To assist in development of Web service clients, RAD provides the following features:
Java client proxy from WSDL: The Web Service client wizard assists us in generating a proxy
JavaBean. This proxy can be used within a client application to greatly simplify the client programming
required to access a Web Service.
Sample Web application from WSDL: Rational Application Developer can generate a sample
Web application, which includes the proxy classes described above, and sample JSP s that use the
proxy classes.

2.4

Testing Tools

To allow developers to test Web services, RAD provides a range of features:


WebSphere Application Server V6.1, V6.0 and V5.1Test Environment: These Test Environments are
included with Rational Application Developer as a test server and can be used to host Web services. It
provides a range of Web services runtimes, including an implementation of the J2EE specification standards.
Sample JSP application: The sample Web application mentioned in Section 2.3 can be used to test
Web services and the generated proxy it uses.
Web Services Explorer: This is a simple test environment that can be used to test any Web Service,
based only on the WSDL file for the service. The service can be running on a local test server or anywhere
else on the network.
Universal Test Client: The Universal Test Client (UTC) is a very powerful and flexible test application
that is normally used for testing EJBs. Its flexibility makes it possible to test ordinary Java classes, so it can
be used to test the generated proxy classes created to simplify client development.
TCP/IP Monitor: The TCP/IP Monitor works like a proxy server, passing TCP/IP requests on to another
server and directing the returned responses back to the originating client. In the process of doing this, it
records the TCP/IP messages that are exchanged, and can display these in a special view within Rational
Application Developer.
Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Web Service using RAD 7.5

Last save on

Page

17/11/2014

8/38

Version
2.1

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

9/38

Version
2.1

3 WEB SERVICE USING RAD 7.5 (JAX RPC, SOAP 1.1)


3.1

Scope of the Proof of Concept

In this section we aim to develop a simple web service using the bottom up approach wherein we use a
simple Java Bean to develop a web service along with a test client and deploy the same on a Websphere
V6.1 application server. The goal of the POC is to provide a secure feeling on the development and
deployment of web services application using the new AAB infrastructure as part of WAS 6.1 migration using
JAX RPC web services runtime environment which uses SOAP 1.1.
The web services application comprises of 3 projects
1. An EAR project SampleWebService which contains the below mention web projects
2. A Dynamic Web Project MyWSWebModule which acts as the server side (Web Service)
3. A Dynamic Web Project MyWSWebClient which acts as the client to access the Web Service.
The EAR is deployed on a Websphere Application Server V6.1 environment.
A pre-requisite for the support of Web Services on RAD 7.5 (and deployment on the local WebSphere
Application Server 6.1) is the installation of the WebSphere 6.1 Feature Pack for Web Services.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

3.2

Last save on

Page

17/11/2014

10/38

Version
2.1

Creating Web Services from a Java Bean

Step 01
Create the EAR project SampleWebService and the 2 Dynamic Web Projects MyWSWebModule &
MyWSWebClient in RAD 7.5 using the following link,
File -> New -> Project -> Java EE -> Enterprise Application Project
File -> New -> Project -> Web -> Dynamic Web Project
Step 02
Add the 2 modules (web projects) to the EAR.

Step 03
Create a new Java Bean EmployeeInfo.java in MyWSWebModule under the following package
com.abnamro.nl.employee

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

11/38

Version
2.1

Note the following code extract,


public EmployeeCustomDTO readEmployeeDetails(String employeeId) {
EmployeeCustomDTO empResultDTO = null;
empResultDTO = getEmployeeInfo(employeeId);
return empResultDTO;
}
In this web service we are exposing the operation readEmployeeDetails() which enables the client to this
web service to retrieve the employee details of an employee (contained in the output object
EmployeeCustomDTO) using an input string, Employee Id.
The Employee Custom DTO has the following attributes,
private String empName = null; //Employee Name
private String empDesignation = null; //Employee Designation
private String empExperience = null; //Employee Experience
private String empAddress = null; //Employee Address
private int empContact = 0; //Employee Contact
private String empSkill = null; //Employee Skill
private boolean isEmployee = false; //Employee exists in the system
private String empID = null; //Employee ID
The Business logic currently resides in the private method getEmployeeInfo(). Currently the business logic
states that data can be retrieved for only one user with employee id 137431. The private method is basically
the entry point to the application logic tier followed by business tier & finally the EIS tier. However the

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

12/38

Version
2.1

implementation for the same is outside the scope for this POC. We will only concentrate on developing a
web service with dummy business logic.
Step 04
To create the Web Service from the Java Bean perform the following,
Right click on EmployeeInfo.java and select Web services -> Create Web service.
The Web Service wizard starts

Select the Web Services options in the Web Services page:


Select Bottom up Java bean Web service as your Web service type.
This should be selected by default.
Ensure that the following server-side configurations are selected:
Server: WebSphere v6.1 Server
Web service runtime: IBM WebSphere JAX-RPC
Service project: MyWSWebModule
Service EAR project: SampleWebService

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

13/38

Version
2.1

Step 05
If you click the hyperlink Server: WebSphere v6.1 Server, the Service Deployment Configuration
dialog is displayed as shown below,

This page allows you to select the server and runtime. We select the recommended Web service runtime to
use within Rational Application Developer which is the WebSphere JAX-RPC Web services runtime.
Axis runtime shipped with Application Developer v7 (Axis v1.3) is a J2SE SOAP engine and it supports the
JAX-RPC standard. It does not require a J2EE container.
The WebSphere JAX-RPC Web service runtime is derived from Apache Axis, but has diverged and contains
many enhancements, such as improved performance, WS-Security, multi-protocol support, J2EE
compliance, in-process optimization, compression, smart parsing, and other enhancements.
Clear Publish the Web service (we do not publish to a UDDI registry) and
Click Next in the Web Services page.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

14/38

Version
2.1

Step 06
In the Service Endpoint Interface Selection dialog, accept the default settings and click Next
Web services must comply with the WS-I basic profile version 1.1.

Step 07
In the Web Service dialog, accept the default options and click Next

On clicking the Next button, the WSDL file EmployeeInfo.wsdl is created and the method
readEmployeeDetails() is the operation exposed by the service.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Web Service using RAD 7.5

Last save on

Page

17/11/2014

15/38

Version
2.1

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

16/38

Version
2.1

Step 08
Click Start Server. It takes a while to start the server. After the server is started, click Next or Cancel.

For our understanding purpose, we stop the server and scan through the directory structure of
MyWSWebModule project in the following section.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

3.3

Last save on

Page

17/11/2014

17/38

Version
2.1

Generated Files in Web Service

The WSDL for the web service is created at the following path,
MyWSWebModule -> WebContent -> WEB-INF -> wsdl -> EmployeeInfo.wsdl
The web service location is mentioned in the created WSDL file,
<wsdlsoap:address
location="http://localhost:9080/MyWSWebModule/services/EmployeeInfo"/>
This WSDL is used by the application server for deployment purposes, and is accessible to external clients
through HTTP.
The wizard generates a number of files which are discussed below. Since the original Java classes are
located in the MyWSWebModule project, all of the generated code is located in the same project.
The service endpoint interface (EmployeeInfo_SEI.java) is the Java interface that is
implemented by the Web Service. This will include a subset of the public methods on the class that
haves been exposed in the Web service.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

18/38

Version
2.1

Web services deployment descriptor (web.xml & webservices.xml) contains


information used by the server to deploy the Web services in the project. The format of this file is defined
by the Web Services for J2EE specification.
WebSphere bindings file (ibm-webservices-bnd.xmi) is used to map local names to global
names (for example, to map EJB references to real names used to register EJBs in JNDI).
WebSphere extensions file (ibm-webservices-ext.xmi) stores information relating to
WebSphere extensions to the J2EE specification. This acts as an extension to the information contained
within the deployment descriptor.
WebSphere bindings file and WebSphere extensions file are also used to configure the WSSecurity. The WebSphere extensions file defines the settings that are going to be used and the
extensions file is used to specify how the declared settings are implemented.
JAX-RPC type mapping file (EmployeeInfo_mapping.xml) contains information on the
relationships between types used in Java code and their equivalents in XML.
*_Ser provides the bean serializer for converting the Java object to an XML complex type. *_Deser
provides the bean deserializer for converting the XML complex type to Java object. *_Helper helps the
Web services engine locate the proper serializer and deserializer for the Java object.
In the following Section we will generate the client to test the web service developed in this section.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

19/38

Version
2.1

4 GENERATING THE WEB SERVICE CONSUMER (SOAP 1.1)


4.1

Test Approach 1: Test with Web Services Explorer

Click on the following link, EmployeeInfo.wsdl (in MyWSWebModule) -> Web Services -> Test with Web
Services Explorer

The following screen applies,

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

20/38

Version
2.1

Note the following in the above Test Client interface,


The Web Service end point is: http://localhost:9082/MyWSWebModule/services/EmployeeInfo
The supported operation is readEmployeeDetails().
Click on the operation to perform the test and specify input employeeId parameter. Ensure that the
application server is started.

Following is the response from the web service,

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

21/38

Version
2.1

The SOAP Request Envelope (sent from client to server) is,


- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://employee.nl.abnamro.com"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <q0:readEmployeeDetails>
<employeeId>137431</employeeId>
</q0:readEmployeeDetails>
</soapenv:Body>
</soapenv:Envelope>
The SOAP Response envelope (received from server to client) is,
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <readEmployeeDetailsResponse xmlns:p783="http://employee.nl.abnamro.com">
- <readEmployeeDetailsReturn>
<empID>137431</empID>
<employee>1</employee>
<empName>Anirban Ganguly</empName>
<empDesignation>ITA</empDesignation>
<empExperience>6 Years</empExperience>
<empAddress>Yantra Park, Thane</empAddress>
<empContact>1111</empContact>
<empSkill>JAVA / J2EE</empSkill>
</readEmployeeDetailsReturn>
</readEmployeeDetailsResponse>
</soapenv:Body>
</soapenv:Envelope>

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

4.2

Last save on

Page

17/11/2014

22/38

Version
2.1

Test Approach 2: Generate Client and Sample JSP

In order to generate the client side proxy classes, select the following link,
Right Click on EmployeeInfo.wsdl -> Web Services -> Generate Client

The following wizard appears,

Client on the Client Project link and update the client project to, MyWSWebClient.
Click on Next button to navigate to the screen shown below.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

23/38

Version
2.1

Select the output folder as MyWSWebClient/src and the package name as com.abnamro.nl.employee.
Click on the Finish button to generate the client.

In order to generate sample JSP s for testing the application do the following,
Right Click on com.abnamro.nl.amployee.EmployeeInfoProxy.java -> Web Services -> Generate Client

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

24/38

Version
2.1

The following sample JSP s are created in MyWSWebClient -> WebContent -> sampleEmployeeInfoProxy

The web service application can now be tested by starting up the application server and keying in the
following URL on the browser,

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

25/38

Version
2.1

Descriptor output is shown below on clicking the Invoke button,

Read Employee Details output is shown below on clicking the Invoke button,

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

4.3

Last save on

Page

17/11/2014

26/38

Version
2.1

View in TCP IP Monitor

The TCP/IP Monitor is also started. The TCP/IP Monitor lets us intercept and examine the SOAP traffic
coming in and out of a Web service.
If you invoke the getEndpoint method in the Sample JSP page gives us the following URL
http://localhost:9082/MyWSWebModule/services/EmployeeInfo
The port number for TCP IP is 6995 which can be verified through the following link,
Window Preferences Run/Debug TCP/IP Monitor
When the TCP/IP Monitor is started it is ready to listen to the SOAP request at port 6995 and the traffic gets
redirected to the TCP IP console with the following end point,
http://localhost:6995/MyWSWebModule/services/EmployeeInfo
Also of significance is that we are using HTTP POST method for the request and HTTP version is 1.1.
This is determined from the following in the screenshot above, (alternative is to use Firefox)
Header: POST/MyWSWebModule/services/EmployeeInfo HTTP 1.1
To learn more about the key difference between HTTP 1.0 & HTTP 1.1 please refer to the following links,
http://www.research.att.com/~bala/papers/h0vh1.html
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

27/38

Version
2.1

The following example is a sample of SOAP 1.1 request and response.


SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://employee.nl.abnamro.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:readEmployeeDetails>
<employeeId>137431</employeeId>
</q0:readEmployeeDetails>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
<soapenv:Header/>
<soapenv:Body>
<p783:readEmployeeDetailsResponse xmlns:p783="http://employee.nl.abnamro.com">
<readEmployeeDetailsReturn>
<empID>137431</empID>
<employee>1</employee><empName>Anirban Ganguly</empName>
<empDesignation>ITA</empDesignation>
<empExperience>6 Years</empExperience>
<empAddress>Yantra Park, Thane</empAddress>
<empContact>1111</empContact>
<empSkill>JAVA / J2EE</empSkill>
</readEmployeeDetailsReturn>
</p783:readEmployeeDetailsResponse>
</soapenv:Body>
</soapenv:Envelope>

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

28/38

Version
2.1

5 WEB SERVICE USING RAD 7.5 (JAX WS 2.0, SOAP 1.2)


In this section we aim to develop a simple web service using the bottom up approach wherein we use a
simple Java Bean to develop a web service along with a test client and deploy the same on a WebSphere
V6.1 application server. The goal of the POC is to provide a secure feeling on the development and
deployment of web services application using the new AAB infrastructure as part of WAS 6.1 migration using
JAX WS 2.0 web services runtime environment using SOAP 1.2.
This section includes the following tasks:
Installing the Web Services Feature Pack (click on Check for updates on the Install page of the
Installing Packages wizard in IBM Installation Manager)
Enabling the WAS V6.1 test environment with the Feature Pack for Web Services
Creating a Web service and a client using the JAX-WS runtime
Sending binary data using MTOM
The web services application comprises of 3 projects as in the earlier example
4. An EAR project SampleWebServiceSOAP12 which contains the below mention web projects
5. A Dynamic Web Project MyWSWebModuleSOAP12 which acts as the server side (Web Service)
6. A Dynamic Web Project MyWSWebClientSOAP12 which acts as the client to access the Web Service.
The EAR is deployed on a WebSphere Application Server V6.1 environment (server is highlighted).

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

29/38

Version
2.1

The same EmployeeInfo bean is reused in this example. The subsequent slides show the creation of the web
service WSDL file & server side proxy classes. To generate the same we need to follow the following link,
Right click on EmployeeInfo bean withinMyWSWebModuleSOAP12 project -> Web Services -> Create Web
service. Select the WebSphere V6.1 server where you wish to deploy the web service and the runtime
environment is IBM WebSphere JAX WS.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Web Service using RAD 7.5

Last save on

Page

17/11/2014

30/38

Version
2.1

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

31/38

Version
2.1

The SOAP 1.2 Binding specification is set in the wizard as shown in the screen below.
Case 1: The JAVA to WSDL mapping style is set to RPC.

Case 2: The JAVA to WSDL mapping style is set to Document Wrapped and MTOM Support is enabled.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

32/38

Version
2.1

Next we proceed to starting the server and testing the application after creating the client via normal
procedure as mentioned in the earlier section.

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

5.1

Last save on

Page

17/11/2014

33/38

Version
2.1

Server Side Generated Code

The server side class EmployeeInfoDelegate.java has the following entry, (SOAP 1.2 specification)
Case 1: If JAVA to WSDL mapping is RPC,
@javax.jws.WebService (targetNamespace="http://employee.nl.abnamro.com/",
serviceName="EmployeeInfoService", portName="EmployeeInfoPort",
wsdlLocation="WEB-INF/wsdl/EmployeeInfoService.wsdl")
@javax.xml.ws.BindingType
(value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
@javax.jws.soap.SOAPBinding(style = javax.jws.soap.SOAPBinding.Style.RPC)
Where,
public static final java.lang.String SOAP12HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";

Case 2: If JAVA to WSDL mapping is Document Wrapped,


@javax.jws.WebService (targetNamespace="http://employee.nl.abnamro.com/",
serviceName="EmployeeInfoService", portName="EmployeeInfoPort",
wsdlLocation="WEB-INF/wsdl/EmployeeInfoService.wsdl")
@javax.xml.ws.BindingType
(value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING)
Where,
public static final java.lang.String SOAP12HTTP_MTOM_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/?
mtom=true";

5.2

Generated WSDL

Also noteworthy is the following difference,

5.2.1

WSDL (EmployeeInfoService.wsdl) with SOAP 1.2 specifications

<?xml version="1.0" encoding="UTF-8"?>


<definitions name="EmployeeInfoService"
targetNamespace="http://employee.nl.abnamro.com/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://employee.nl.abnamro.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Case 1: If JAVA to WSDL mapping is RPC,
<soap12:binding style="rpc"
transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"/>
Case 2: If JAVA to WSDL mapping is Document Wrapped,
<soap12:binding style="document"
transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"/>

5.2.2

WSDL (EmployeeInfo.wsdl) with SOAP 1.1 specifications

<?xml version="1.0" encoding="UTF-8"?>


<wsdl:definitions targetNamespace="http://employee.nl.abnamro.com"
xmlns:impl="http://employee.nl.abnamro.com"
Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

34/38

Version
2.1

xmlns:intf="http://employee.nl.abnamro.com"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>

5.2.3

SOAP Request Response

Following is the test screen for the Web Service,

The TCP IP Monitor where the SOAP request response is trapped is shown below,

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

5.2.3.1

Last save on

Page

17/11/2014

35/38

Version
2.1

SOAP 1.2 request and response (RPC)

SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<rpcOp:readEmployeeDetails xmlns:rpcOp="http://employee.nl.abnamro.com/">
<arg0>137431</arg0>
</rpcOp:readEmployeeDetails>
</soapenv:Body>
</soapenv:Envelope>
SOAP Reponse
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<rpcOp:readEmployeeDetailsResponse xmlns:rpcOp="http://employee.nl.abnamro.com/">
<return>
<empAddress>Yantra Park, Thane</empAddress>
<empContact>1111</empContact>
<empDesignation>ITA</empDesignation>
<empExperience>6 Years</empExperience>
<empID>137431</empID>
<empName>Anirban Ganguly</empName>
<empSkill>JAVA / J2EE</empSkill>
<employee>true</employee>
</return>
</rpcOp:readEmployeeDetailsResponse>
</soapenv:Body>
</soapenv:Envelope>
5.2.3.2

SOAP 1.2 request and response (Document Wrapped with MTOM)

SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body><ns2:readEmployeeDetails xmlns:ns2="http://employee.nl.abnamro.com/">
<arg0>137431</arg0>
</ns2:readEmployeeDetails>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
--MIMEBoundaryurn_uuid_D4DFDF7EBA2C6ECCA21248249302772
content-type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
content-transfer-encoding: binary
content-id: <0.urn:uuid:D4DFDF7EBA2C6ECCA21248249302773@apache.org>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

36/38

Version
2.1

<ns2:readEmployeeDetailsResponse xmlns:ns2="http://employee.nl.abnamro.com/">
<return><empAddress>Yantra Park, Thane</empAddress>
<empContact>1111</empContact>
<empDesignation>ITA</empDesignation>
<empExperience>6 Years</empExperience>
<empID>137431</empID>
<empName>Anirban Ganguly</empName>
<empSkill>JAVA / J2EE</empSkill>
<employee>true</employee>
</return></ns2:readEmployeeDetailsResponse>
</soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_D4DFDF7EBA2C6ECCA21248249302772--

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

37/38

Version
2.1

6 CONCLUSION
The IBM WebSphere Application Server, Version 6.1 Feature Pack for Web Services upgrades IBM WAS
V6.1 to V6.1.0.9 and installs the runtime required to support the Feature Pack for Web Services. The WAS
Version 6.1 Feature Pack for Web Services extends the capabilities of WAS V6.1 to enable Web services
messages to be sent asynchronously, reliably, and securely, focusing on interoperability with other vendors
and to provide support for the Java API for XML Web Services (JAX-WS) 2.0 programming model.
Rational Application Developer v7.5 contains new installable product features including Web Services
Feature Pack and IBM WAS Version 6.1 Feature Pack for Web Services.
The Feature Pack for Web Services includes support for:
New Web services standards, including:
Web Services Reliable Messaging (WS-RM)
Web Services Addressing (WS-Addressing)
SOAP Message Transmission Optimization Mechanism (MTOM)
New standards-based programming model support:
Java API for XML Web Services (JAX-WS 2.0)
Java Architecture for XML Binding (JAXB 2.0)
SOAP 1.2
SOAP with Attachments API for Java (SAAJ 1.3)
JAX-WS is an API defined in the standard JDK. Sun provides a reference implementation for this API. IBM
delivers another implementation in its Web Service Feature Pack. JAX-WS implemented by WAS6.1 Feature
Pack for Web Services must be used as the standard to provide web services and to consume web services

JAX-WS is a relatively new standard defined in the JDK. Therefore we expect it will be better
supported and have a longer lifecycle then a pure open-source product such as AXIS2.
JAX-WS is shipped with WAS in the form of a feature pack
A common set of binding rules for XML and Java objects make it easy to incorporate XML data and
processing functions in Java applications; and a further set of enhancements help us send binary
attachments, such as images or files, with the Web service request in an optimal way.

Web services must comply with the WS-I basic profile version 1.1 because of the following rationale,
Ensure interoperability between all kinds of provider and consumer platforms
Version 1.1 is the most recent final version
SOAP Message Transmission Optimization Mechanism (MTOM) is a standard that is developed by the World
Wide Web Consortium (W3C). MTOM describes a mechanism for optimizing the transmission or wire format
of a SOAP message by selectively re-encoding portions of the message while still presenting an XML
Information Set (Infoset) to the SOAP application. MTOM uses the XML-binary Optimized Packaging (XOP)
in the context of SOAP and MIME over HTTP.
Web Services must use MTOM (Message Transmission Optimization Mechanism) to send and receive
binary data because of the following rationale,

Web Service using RAD 7.5

Template Version: 1.0

Subject

Developing Web Service using RAD 7.5 for WAS 6.1

Last save on

Page

17/11/2014

38/38

Version
2.1

Standard and most efficient (compared to encoded formats) solution


Supported by WS-Security solutions
Supported by JAX-WS

For a detailed overview of the differences between SOAP 1.1 & SOAP 1.2 specifications please refer,
http://hadleynet.org/marc/whatsnew.html
The document aims to provide confidence in developing Web Services using RAD 7.5 with different runtime
environments and guides a developer with a step by step approach for the same.

Web Service using RAD 7.5

Template Version: 1.0

You might also like