Oracle9iAS Web Services
provide support for SOAP request headers sent from a Web Services client to
an endpoint.
Oracle9iAS Web Services
generated client-side proxy code provides methods to use SOAP request headers.
The client can create headers with appropriate information and attach it to
the SOAP message using methods provided by the proxy class. The SOAP request
message, including the SOAP request headers is transmitted to the service endpoint
when Web Services proxy code is invoked.
To be able to process header information transmitted from
the client, the Web Service should implement the oracle.j2ee.ws.HeaderCallback
interface that is part of the Oracle9iAS
Web Services supplied wsserver.jar. This interface
includes one method that takes a single org.apache.soap.Header
argument. The Oracle9iAS Web Services
infrastructure calls the processHeaders() method
before every associated service method is executed
When an incoming SOAP request header includes one or more
header entries with the mustUnderstand attribute
set to 1, then the Web Service implementation must implement the oracle.j2ee.ws.HeaderCallback
interface. If this interface is not implemented, Oracle9iAS
Web Services throws a SOAP fault with the fault code set to FAULT_CODE_MUST_UNDERSTAND.
Application Overview
The sample implements an online Flight Booking System maintained
by the Airport authorities. The sample consists of two components:
Flight Booking Application (Fly Purple)
Flight Booking Service
Flight Booking Service
The Flight Booking Service is a Web Service exposed by an
Airlines operator. The Web Service exposes a method to book flight tickets between
cities in which the Airlines operate. The service charges the ticket amount
using a Credit Card. The service processes SOAP headers sent from the client
to get the Credit Card information of the user.
The Web Service rewards users with points when a flight booking
is made under the Frequent Flying Plan system. These points can be availed by
the user to get a discount on the ticket amount for the future bookings. The
Web Service expects the client to pass the frequent flying plan number in a
SOAP Header. If the user provides the frequent flying plan number, the Web Service
parses the header, retrieves the plan number and provides the discount based
on the number of points accumulated by the user before charging the Credit Card.
The frequent flying number is optional. If not provided, the Web Service ignores
it and charges the full amount on the Credit Card.
On successful validation of Credit Card information, the
Web Service persists the booking information in the database and returns the
booking Id to the client.
The Flight Booking Web Service exposes another method to
get the currency exchange rate between two countries. The names of two countries
are retrieved from the header passed along with the SOAP request from the client.
The Web Service in turn calls the Currency Exchange Rate
service running live on xmethods.net at this
URL to get the exchange rate between currencies of the two countries.
Flight Booking Application
The application allows the user to search and book a flight
between two cities on a particular date and time. For booking the ticket, user
has to pay the ticket amount using a Credit Card. The user can also provide
frequent flying plan number to get discount on the ticket amount.
The application displays the booking amount in US dollar
and also in the local currency of the user. The application retrieves the user's
location information from the locale set in the client browser. The application
invokes the Flight Booking Web Service to get the currency exchange rate between
user's country and the US. The names of countries is passed to the Web Service
in the header of SOAP request.
The flight details submitted by the user will be passed
by the booking application to the Web Service for processing. The flight details
will be passed as a part of SOAP message body to the Web Service. The Credit
Card details will be passed as a SOAP header to the Web Service with mustUnderstand
attribute set to true i.e. the Web Service should process the header and confirm
the validity of the card.
If the user provides the frequent flying plan number while
booking, it is passed as another header from the client (the booking system)
to the Web Service with mustUnderstand attribute
set to false.
Fig 1 shows the block diagram of the way the sample implements
the system for booking tickets.
Fig 1
The application implements Model View Controller architecture
using the Struts framework.
Note : In this sample application, for illustration
purpose, we are passing the Currency information (from User Locale), Credit
Card Details and Frequent Flyer Plan number in a SOAP Header. In other situations,
it is highly likely that the developer wish to pass transaction information,
language information, session information etc as a SOAP Header. The concepts
illustrated in this sample application can be easily extended to cater to such
situations.