Web Service SOAP Headers Sample

This document is consists of following sections:

Overview of the Sample Application 

Technology Overview

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.

Installation and Configuration 

Back to Top

Refer Install file in the sample jar for configuring and running the sample application.
 
 

Description of Sample Files 

Back to Top

Following is the directory structure of Flight Booking Application. SOAPHeaderSample is the sample's top level directory.

Directory File Description
/doc Readme.html This file
Install.html Sample installation file.
/FlightSystem/jsps *.jsp All the JSP files used by the application
/FlightSystem/jps/includes   All the images and doc files used by JSP files.
/FlightSystem/jps/WEB-INF web.xml Web Descriptor file for Flight Booking application
*.tld Tag library files used by Struts
/FlightSystem/jps/WEB-INF/lib   Consists of jar files used by Struts.
/FlightSystem/src/oracle/ otnsamples/soapheader/flightsystem/actions
MainAction.java This Struts Action class retrieves cities info from database and displays it on main page of application.
SelectFlightAction.java This Action class gets all the flights between selected cities from database.
PayAction.java This Action class gets payments details of flight from database. It also calls web service to get local currency exchange rate.
BookAction.java This Action class calls Web Service to book ticket.
/FlightSystem/src/oracle/ otnsamples/soapheader/flightsystem/formbean MainFormBean.java PayFormBean.java The bean files used by struts framework to pass user input to Action classes.
/FlightSystem/src/oracle/ otnsamples/soapheader/flightsystem/model FlightDataManager.java This file defines all the database operations for the application.
FlightBean.java The Java bean to store flight details.
/FlightSystem/src/oracle/ otnsamples/soapheader/flightsystem/utils ClientSOAPHeaders.java This file creates SOAP header elements to be passed from client to Web Service with SOAP request.
 
/WebService/src/oracle/otnsamples/soapheader
/webservice
FlightBookingService.java Web Service implementation class file.
IFlightBookingService.java Web Service interface.
BookingDataManager.java This file manages database operations for the Web Service.
BookingDetails.java The Java bean to store booking details.
CurrencyExchangeServiceStub.java The proxy class to access Exchange Rate Service on xmethods.net.
/WebService config.xml The config file used by Web Service Assembler tool.

Please enter your comments about this sample in the OTN Sample Code Discussion Forum.

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy