Java Sample 3:
Retrieving Flight Information

This example takes the response data from the air booking in Sample 1 to retrieve Flight Information (commonly known as FLIFO). Flight Information eBL accepts a list of flights and returns all relevant details for each flight. Please note that various levels of Flight Information are not supported on all airlines.

Flight Information calls can be made through either Flight Information eBL or by using the FlightInfo_6_0 transaction in the XML Select Web Service. In this example, the Flight Information eBL is used.

  1. Create a proxy of the XML Select Web Service, using a WSDL for your region or service level. For example:
    https://americas.copy-webservices.travelport.com/B2BGateway/service/FlightInformation?WSDL
    .

  1. Create a function, FWSController, which formats an XML template, retrieves the required data from the AirAvailability_6_5 response, and sets the parameters for the request. This example assumes that the proxy server credentials have already been identified in the system properties. This method can be used in Apache Axis.

 

package com.galileo.GWSGettingStarted;

 

import java.io.StringReader;

 

import java.text.MessageFormat;

 

import java.util.Calendar;

 

 

 

import org.apache.axis.utils.XMLUtils;

 

import org.w3c.dom.Element;

 

import org.w3c.dom.NodeList;

 

 

 

import com.galileo.webservices.
FlightInformationWebServiceLocator;

 

import com.galileo.webservices.
FlightInformationWebServiceSoapStub;

 

 

Declares the FWSController class, which manages the Flight Information eBL request.

public class FWSController {

public FWSController() {}

Makes the Flight Information eBL call.

public Element DoFlightInformation( Element fwsRequest)

 

{

 

Element responseElement = null;

 

try

 

{

Instantiates the locator.

FlightInformationWebServiceLocator fservice = new FlightInformationWebServiceLocator();

Uses the Web Service to get a stub, which implements the SDI.

FlightInformationWebServiceSoapStub fws =  (FlightInformationWebServiceSoapStub)
fservice.getFlightInformationWebServiceSoap
(new java.net.URL(FWS_ENDPOINT));

The User Name and Password to access Galileo Web Services.

fws.setUsername(USER_NAME);

fws.setPassword(PASSWORD);

To receive full response data, a Host Access Profile (HAP) is required for each CRS, Galileo and Apollo. See How Flight Information eBL Works for more information.

responseElement = fws.getInformation(  GALILEO_HAP , APOLLO_HAP, fwsRequest);

Exception handling.

catch (Exception e)

{

System.err.println(e.getMessage());

e.printStackTrace(System.err);

}

return responseElement;

 

}

Reads an XML Select availability response and populates a Flight Information eBL request with the appropriate information.

public Element CreateRequest(Element xmlAirAvail)

 

{

Gets the required information from the AirAvailability_6_2 response.

NodeList allSegments = xmlAirAvail.getElementsByTagName("AvailFlt");

if (allSegments.getLength() == 0)

return null;

 

 

 

Element firstSegment = (Element)allSegments.item(0);

 

 

Gets the departure and dates and times.

String dt = GetText(firstSegment, "StartDt");

String tm = GetText(firstSegment, "StartTm");

Calendar departDateTime = parseHostDate(dt, tm);

 

 

Gets the flight number.

String flightNum = GetText(firstSegment, "FltNum");

Gets the departure airport.

String departAirport = GetText( firstSegment, "StartAirp");

Gets the arrival airport.

String arriveAirport = GetText( firstSegment, "EndAirp");

Gets the air vendor code.

String airline = GetText(firstSegment, "AirV");

 

 

 

StringBuffer req = new StringBuffer();

Makes the Flight Information eBL request. The namespace is defined in the WSDL, whether ns.galileo.com or webservices.galileo.co

req.append("<GWS_FlightInformationRQ xmlns='http://ns.galileo.com'>");

Request for all flight segments.

req.append("    <Flights>");

Flight segment request. The <Flight> element is repeated as necessary for additional segments.

req.append("        <Flight ");

Airline vendor code.

req.append("airline='" + airline +"' ");

Flight number.

req.append("number='" + flightNum +"' ");

Departure date.

req.append("date='" + MessageFormat.format
("{0,date,yyyy-MM-dd}", new Object []
{departDateTime.getTime()}) + "' ");

Departure airport.

req.append("orig='" + departAirport + "' ");

Arrival airport.

req.append("dest='" + arriveAirport + "' />");

End of the Flight Information eBL request.

req.append("        </Flights>");

End of the Flight Information eBL request.

req.append("    </GWS_FlightInformationRQ>");

 

 

 

return Util.string2Element(req.toString());

 

}

GetText is a utility class that gets the content of the node pointed to by an XPath. Returns an empty string if there is no text or if the node does not exist.

private String GetText(Element inNode, String nodeName)

{

NodeList tempNodes = inNode.getElementsByTagName(nodeName);

if (tempNodes.getLength() == 0)

return "";

return tempNodes.item(0).getFirstChild().getNodeValue();

}

Parses the CRS date and time format (YYMMDD) into a Calendar object.

private Calendar parseHostDate(String date, String time)

{

Calendar dt = Calendar.getInstance();

int y = Integer.parseInt(date.substring(0,4));

int M = Integer.parseInt(date.substring(4,6));

int d = Integer.parseInt(date.substring(6,8));

int h = Integer.parseInt(time.substring(0,2));

int m = Integer.parseInt(time.substring(2,4));

dt.set( y, M, d, h, m);

return dt;

}

 

 

Declares the constants. Ensure URL is specific to your region or service level.

private final String FWS_ENDPOINT = "https://americas.copy-webservices.travelport.com/B2BGateway/service/FlightInformation";

private final String USER_NAME = "UserName";

private final String PASSWORD = "Password";

private final String GALILEO_HAP = "Galileo_HostAccessProfile";

private final String APOLLO_HAP = "Apollo_HostAccessProfile";

 

}

 

  1. The Apollo or Galileo CRS returns the following Flight Information eBL response.

Flight Information eBL response.

<GWS_FlightInformationRS version="1.0.39.0" dateTime="2002-09-26T14:48:05:515Z" profileApollo="GalileoProd_APD" profileGalileo="ApolloProd_APD" xmlns="http://ns.galileo.com">

Flight response.

The <Flight> section root element is essentially the same as the request, with the addition of a "source" attribute.

<Flights>

Airline vendor code, flight number, departure date, and departure and arrival airports.

The  "source" attribute allows clients to correlate flights in the request to flights in the response.

<Flight airline="UA" number="258" date="2002-12-25" orig="DEN" dest="ORD" source="schedule">

An array of messages that apply to the entire trip, if available.

<Messages />

The <City> element indicates additional segment information.  Intermediate stops contain both departure and arrival data for the city. <Departure> elements may indicate a meal or equipment type.

Variances indicate any deviation between scheduled, updated, and real-time data.

Real-time data displays only for airline vendors that specifically supply this information.

<Cities>

<City code="DEN">

<Departure scheduledDateTime="2002-12-25T11:50:00" meal="unknown">

<Variances />

</Departure>

</City>

<City code="ORD">

<Arrival scheduledDateTime="2002-12-25T15:14:00">

<Variances />

</Arrival>

</City>

</Cities>

End of the flight segment information.

</Flight>

End of the flight information.

</Flights>

Flight Information eBL calls the Travel Codes Translator eBL to decode the airline vendor and airport codes into natural language.

<Decode xmlns="http://ns.galileo.com">

<Airline Code="UA">United</Airline>

<Airport Code="DEN" StateProvinceCode="CO" CountryCode="US">Denver Intl Arpt</Airport>

<Airport Code="ORD" StateProvinceCode="IL" CountryCode="US">O'Hare Intl Arpt</Airport>

</Decode>

End of the Flight Information eBL response.

</GWS_FlightInformationRS>

 

  1. After retrieving the flight information, use the Reservation Builder eBL to cancel the PNR/Booking File in Sample 4.