Perl Sample Step 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 either through the 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 FlightInformation controller, which formats an XML template, retrieves the required data from the AirAvailability_6_5 response, and sets the parameters for the request. The following code also contains proxy server credentials that are included with the request to bypass the firewall.

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

package Controllers::FlightInformation;

 

use SOAP::Lite +trace => 'debug';

 

use XML::Simple;

 

 

Creates and sets up the credentials for Flight Information eBL. The user name and password are assigned by Galileo.

Note
: Credentials are only required for one file in a module.  However, the credentials are included in each sample Controller so that they can function as stand-alone samples.

 

our $USER_NAME = "USERNAME";

our $PASSWORD  = "PASSWORD";

sub SOAP::Transport::HTTP::Client::get_basic_credentials {

return $USER_NAME => $PASSWORD;

 

}

 

 

The constructor for Flight Information eBL.

sub new {

 

my $type = shift;

 

my $self = {};

Defines the Host Access Profile, which is required to access Galileo Web Services.

$self->{ApolloHAP} = "ApolloHostAccessProfile";

$self->{GalileoHAP} = "GalileoHostAccessProfile";

Declares and initializes variables for the required namespaces and Flight Information eBL endpoint.

$self->{NAMESPACE} = 'http://webservices.galileo.com/FlightInformation';

$self->{ENDPOINT} = 'https://americas.copy-webservices.travelport.com/B2BGateway/service/FlightInformation.asmx';

 

return bless $self, $type;

 

}

 

 

Builds an XML document using booking information from the first segment of the valid Air Availability response.

sub BuildRequest

{

my $self = shift;

my $xmlAirAvail = shift;

my $xs = new XML::Simple();

my $availRef = $xs->XMLin($xmlAirAvail);

my $allSegments = $availRef->{'soap:Body'}->{SubmitXmlResponse}->{SubmitXmlResult}->{AirAvailability_6_2}->{AirAvail}->{AvailFlt};

my $firstSegment = $allSegments->[0];

Gets the departure dates and times.

my @departDate;

$departDate[0] = substr($firstSegment->{StartDt}, 0 ,4);

$departDate[1] = substr($firstSegment->{StartDt}, 4, 2);

$departDate[2] = substr($firstSegment->{StartDt}, 6, 2);

$departDate[3] = substr($firstSegment->{StartTm}, 0, 2);

$departDate[4] = substr($firstSegment->{StartTm}, 2, 2);

Gets the flight number.

my $flightNum =  $firstSegment->{FltNum};

Gets the departure airport.

my $departAirport = $firstSegment->{StartAirp};

Gets the arrival airport.

my $arriveAirport = $firstSegment->{EndAirp};

Gets the air vendor code.

my $airline = $firstSegment->{AirV};

 

my $req = "";

Makes the Flight Information eBL request.

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

Request for all flight segments.

$req .= "    <Flights>";

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

$req .= "        <Flight ";

Airline vendor code.

$req .= "airline='$airline' ";

Flight number.

$req .= "number='$flightNum' ";

Departure date.

$req .= "date='" . sprintf("%04d-%02d-%02d", @departDate) . "' ";

Departure airport.

$req .= "orig='$departAirport' ";

Arrival airport.

$req .= "dest='$arriveAirport' />";

End of the flight request.

$req .= "        </Flights>";

End of the Flight Information request.

$req .= "    </GWS_FlightInformationRQ>";

 

return $req;

 

}

 

 

Submits the Flight Information eBL call.

sub doFlifo

 

{

 

my $self = shift;

Wraps the input parameters with the appropriate parameter names. SOAP::Lite does support this function for complex types, such as XML.

my $request = '<xmlRequest>'.(shift).'</xmlRequest>';

 

$self->{request} = $request;

Instantiates the FlightInformation Soap::Lite object.

my $webService = SOAP::Lite

Sets the URL of the Soap Proxy.

-> uri($self->{NAMESPACE})

By default, Soap::Lite uses the pound sign (#) to concatenate URLs. Replace the pound sign with a slash (/).

-> on_action(sub{sprintf '%s/%s', @_ })

The default response is a hash value because the return type, xmlelement, is complex. Setting outputxml() to TRUE creates an XML response.

-> outputxml("1")

Sets the proxy endpoint to Flight Information eBL.

-> proxy($self->{ENDPOINT});

Assigns the return value of the Flight Information eBL object's call to the GetInformation method.

my $response = $webService

Sets the namespace for the GetInformation method parameters.

->call(SOAP::Data->name("GetInformation")->attr({xmlns => $self->{NAMESPACE}}),

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.

SOAP::Data->name(profileGalileo => $self->{GalileoHAP})->type('string'),

SOAP::Data->name(profileApollo => $self->{ApolloHAP})->type('string'),

Returns the response data as an XML element.

SOAP::Data->name(xmlRequest => $request)->type('xml'));

Saves the response to the object.

$self->{response} = $response;

 

return $response;

 

}

1;

 


  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 flight segment information.

</Flight>

End of flight information.

</Flights>

Flight Information 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 Flight Information eBL response.

</GWS_FlightInformationRS>

 

  1. After retrieving the flight information, cancel the PNR/Booking File in Sample 4.