Professional Documents
Culture Documents
Version:
TCS Confidential
2.1
Subject
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
Subject
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)
Date
Remarks / Changes
Status
Draftt
Author
Approved
Subject
Last save on
Page
17/11/2014
4/38
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
Subject
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.
Subject
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
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/
Subject
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
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
Subject
Last save on
Page
17/11/2014
8/38
Version
2.1
Subject
Last save on
Page
17/11/2014
9/38
Version
2.1
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.
Subject
3.2
Last save on
Page
17/11/2014
10/38
Version
2.1
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
Subject
Last save on
Page
17/11/2014
11/38
Version
2.1
Subject
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
Subject
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.
Subject
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.
Subject
Last save on
Page
17/11/2014
15/38
Version
2.1
Subject
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.
Subject
3.3
Last save on
Page
17/11/2014
17/38
Version
2.1
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.
Subject
Last save on
Page
17/11/2014
18/38
Version
2.1
Subject
Last save on
Page
17/11/2014
19/38
Version
2.1
Click on the following link, EmployeeInfo.wsdl (in MyWSWebModule) -> Web Services -> Test with Web
Services Explorer
Subject
Last save on
Page
17/11/2014
20/38
Version
2.1
Subject
Last save on
Page
17/11/2014
21/38
Version
2.1
Subject
4.2
Last save on
Page
17/11/2014
22/38
Version
2.1
In order to generate the client side proxy classes, select the following link,
Right Click on EmployeeInfo.wsdl -> Web Services -> Generate Client
Client on the Client Project link and update the client project to, MyWSWebClient.
Click on Next button to navigate to the screen shown below.
Subject
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
Subject
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,
Subject
Last save on
Page
17/11/2014
25/38
Version
2.1
Read Employee Details output is shown below on clicking the Invoke button,
Subject
4.3
Last save on
Page
17/11/2014
26/38
Version
2.1
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
Subject
Last save on
Page
17/11/2014
27/38
Version
2.1
Subject
Last save on
Page
17/11/2014
28/38
Version
2.1
Subject
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.
Subject
Last save on
Page
17/11/2014
30/38
Version
2.1
Subject
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.
Subject
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.
Subject
5.1
Last save on
Page
17/11/2014
33/38
Version
2.1
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/";
5.2
Generated WSDL
5.2.1
5.2.2
Subject
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
The TCP IP Monitor where the SOAP request response is trapped is shown below,
Subject
5.2.3.1
Last save on
Page
17/11/2014
35/38
Version
2.1
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 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
Subject
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--
Subject
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,
Subject
Last save on
Page
17/11/2014
38/38
Version
2.1
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.