Perl Sample 1:
Requesting an Air Availability
Step 1 creates a general air availability request using the XML AirAvailability_6_5 transaction. The sample uses the minimum request parameters needed for availability of a one-way trip (single air segment) from Denver International Airport in Denver to O'Hare International Airport in Chicago. Currently, availability requests can be made only through transactions in the XML Select Web Service.
-
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/XMLSelect?WSDL.
-
Most toolkits do not explicitly support proxies that connect to a Web Service via a secured firewall. See Connecting to Galileo Web Services for more details about working with proxy servers and other authentication issues.
-
Full Perl sample files are available at the Sample Site.
-
Create a function, XWSController, which formats an XML template 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 XWSController class, which manages the XML Select Web Service request. |
package Controllers::XWS; |
|
use SOAP::Lite +trace => 'debug'; |
|
|
Creates and sets up the credentials
for the XML Select Web Service. The user name and password are assigned
by Galileo.
|
our $USER_NAME = "UserName"; |
our
$PASSWORD |
|
sub SOAP::Transport::HTTP::Client::get_basic_credentials { |
|
return $USER_NAME => $PASSWORD; |
|
|
} |
|
|
The constructor for XML Select. |
sub new { |
|
my $type = shift; |
|
my $self = {}; |
Defines the Host Access Profile, which is required to access Galileo Web Services. |
$self->{HAP} = "HostAcessProfile"; |
Declares and initializes variables for the required namespaces and XML Select Web Service endpoint. |
$self->{NAMESPACE} = 'http://webservices.galileo.com'; |
$self->{ENDPOINT} = 'https://americas.copy-webservices.travelport.com/B2BGateway/service/XMLSelect.asmx'; |
|
|
return bless $self, $type; |
|
} |
|
|
Builds an XML document using fixed endpoints and the required date. |
sub BuildRequest |
|
{ |
|
my $self = shift; |
Finds the 15th of the month three months from the current date. |
my $day = "15"; |
my $month = (localtime)[4] + 3; |
|
my $year = (localtime)[5] + 1900; |
|
|
if ($month > 12) |
|
{ |
|
$month -=12; |
|
$year += 1; |
|
} |
XML Select AirAvailability_6_2 transaction. See the AirAvailability_6_2 Sample Request for complete request parameters. |
my $req; |
$req .= "<AirAvailability_6_5>\r\n"; |
|
Air availability request. |
$req
.= " |
General air availability. |
$req
.= " |
Number of seats. |
$req
.= " |
Preferred class of service. If no specific class of service is requested, a CDATA structure is used to force a blank. The CRS will not process a zero value for this element. |
$req
.= " |
Departure date for the flight segment. The CRS processes dates in a yyyyMMdd format. |
$req
.= " |
Departure airport or city. Metro codes can be denoted with an asterisk, e.g., LAX*. |
$req
.= " |
Destination airport or city. |
$req
.= " |
Departure time at noon in a
24-hour clock, HHMM. |
$req
.= " |
Time Window Indicator specifies if a time window applies to a D (departure time/date) or A (arrival time/date). |
$req
.= " |
Start and End Time of Departure/Arrival
Window. Values in a 24-hour clock, HHMM. |
$req
.= " |
$req
.= " |
|
Flight type preference. |
$req
.= " |
Start point indicator. |
$req
.= " |
End point indicator. |
$req
.= " |
Ignore TravelScreen preferences. |
$req
.= " |
End general availability. |
$req
.= " |
End availability request. |
$req
.= " |
End XML Select transaction. |
$req .= "</AirAvailability_6_5>\r\n"; |
|
return $req; |
|
} |
|
|
Builds a default filter that returns flight availability. |
sub BuildFilter |
|
{ |
|
my $self = shift; |
A wildcard filter returns all data for flight availability <AvailFlt>. |
return
"<AirAvailability_6_5><AirAvail><AvailFlt><_/> |
|
} |
|
|
Makes the availability call. |
sub doAvail |
|
{ |
|
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 $xmlFilter = '<Filter>'.(shift).'</Filter>'; |
my $xmlRequest = '<Request>'.(shift).'</Request>'; |
|
Saves the Filter and Request to the object. |
$self->{filter} = $xmlFilter; |
$self->{request} = $xmlRequest; |
|
Instantiates the XWS Soap::Lite object. |
my $xws = SOAP::Lite |
Sets the URL for the XWS 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 XML Select. |
-> proxy($self->{ENDPOINT}); |
|
|
Assigns the return value of the XML Select object's call to the SubmitXml method. |
my $response = $xws |
Sets the namespace for the SubmitXml method parameters. |
->call(SOAP::Data->name("SubmitXml")->attr({xmlns => $self->{NAMESPACE}}), |
A Host Access Profile is required to access Galileo Web Services. |
SOAP::Data->name(Profile => $self->{HAP})->type('string'), |
Specifies the Document (root) XML element for the request and filter. |
SOAP::Data->name(Request => $xmlRequest)->type('xml'), |
SOAP::Data->name(Filter => $xmlFilter)->type('xml')); |
|
Saves the response to the object. |
$self->{response} = $response; |
|
return $response; |
|
} |
-
The Apollo or Galileo CRS returns 16 segments in an XML Select air availability response. The following code shows an example of the air availability summary for all segments as well as the first actual response segment. The complete response with all returned segments is available on the Galileo Web Services Sample Site. See the AirAvailability_6_5 Sample Response for complete response parameters.
XML Select AirAvailability_6_2 transaction. |
<AirAvailability_6_5 xmlns=""> |
Air availability response. |
<AirAvail> |
When additional response segments are available, a More token is returned. A specific More token can only be used once. After each follow-on request, a new token is returned to be used for the next follow-on request. |
<MoreToken> |
<Tok>301060172164629495103170495884 |
|
</MoreToken> |
|
Summary of returned segments. |
<AvailSummary> |
The total number of direct and connecting flight segments in response. The default number of availability responses is 16. |
<NumSegs>16</NumSegs> |
Airport or city code of the customer embarkation. Left justified, blank filled. |
<StartPt>DEN</StartPt> |
City code for requested origin city or airport. |
<StartCity>DEN</StartCity> |
Destination airport or city code. |
<EndPt>ORD</EndPt> |
City code for requested destination city or airport. |
<EndCity>CHI</EndCity> |
Error codes. |
<ErrInd>0</ErrInd> |
<ErrNum>0</ErrNum> |
|
End of summary. |
</AvailSummary> |
Begin data for the first flight segment. |
<AvailFlt> |
Airline carrier (vendor) code. |
<AirV>UA</AirV> |
Flight number. |
<FltNum>262</FltNum> |
Optional suffix. |
<OpSuf /> |
Departure date of segment in YYYYMMDD format. |
<StartDt>20020926</StartDt> |
Departure airport code. |
<StartAirp>DEN</StartAirp> |
Destination airport code. |
<EndAirp>ORD</EndAirp> |
Departure time of this segment in a 24-hour clock HHmm. |
<StartTm>1135</StartTm> |
Arrival time of this flight segment in a 24-hour clock HHmm. |
<EndTm>1455</EndTm> |
Day change indicates the difference between departure and arrival dates. -1, 00, 01, 02 are valid. |
<DayChg>00</DayChg> |
Connection
indicates that this flight segment connects to the next segment in the
response. |
<Conx>N</Conx> |
Indicates a change of airport (crosstown) connection at the board point. Not applicable to the first flight segment of a connection. |
<AirpChg>N</AirpChg> |
Aircraft type. CHG indicates an aircraft change. |
<Equip>777</Equip> |
Reserved for future use. Currently ignored. |
<Spare1 /> |
Number of intermediate stops between board and off points. |
<NumStops>0</NumStops> |
Indicates whether the carrier above differs from the carrier which actually operates the flight (code share). |
<OpAirVInd>N</OpAirVInd> |
On
time performance indicator. |
<Perf>8</Perf> |
Type of sell
agreement between CRS and link carrier. |
<LinkSellAgrmnt>SS</LinkSellAgrmnt> |
Indicates if carrier has link (carrier-specific) display option. |
<DispOption>Y</DispOption> |
Indicates if carrier has Inside (polled) Availability option. |
<InsideAvailOption>L</InsideAvailOption> |
General traffic restriction indicators. |
<GenTrafRestriction /> |
Contains a Y or an N for each day of the week starting with Sunday. Y indicates that the flight operates for that day of the week. |
<DaysOperates>YYYYYYY</DaysOperates> |
Total flying time (in minutes) for all segments of the journey. |
<JrnyTm>140</JrnyTm> |
Arrival Date in YYYYMMDD format. |
<EndDt>20020926</EndDt> |
Code share: Airline code for the carrier that actually operates this flight. Blank if no code share. |
<OpAirV /> |
The operating carrier's flight designator for this flight. Blank if no code share. |
<OpFltDesignator /> |
Reserved for future use. Currently ignored. |
<OpFltSuf /> |
Used only for Flight-Specific Timetable. |
<StartTerminal /> |
Used only for Flight-Specific Timetable. |
<EndTerminal>1</EndTerminal> |
Elapsed flight time in minutes. |
<FltTm /> |
Indicates Last Seat Availability capability. |
<LSAInd>N</LSAInd> |
Carrier is a Galileo Participant. |
<GalileoAirVInd>Y</GalileoAirVInd> |
End data for first flight segment. |
</AvailFlt> |
Begin flight availability status. |
<FltAvailStatus> |
Indicates the operational status of this flight segment. |
<FltStatus /> |
Indicates whether seats are available in First, Business, and Coach class, respectively. A
Seats are available |
<First>A</First> |
<Business>A</Business> |
|
<Coach>A</Coach> |
|
End of flight availability status. |
</FltAvailStatus> |
Begin booking code availability. BIC (Booking Indicator Code) is the same as Class of Service. |
<BICAvail> |
Multiple BIC statuses may be listed, depending on the parameters of the availability request. |
<BICStatusAry> |
<BICStatus> |
|
Booking Indicator Code (Class of Service). |
<BIC>F</BIC> |
The number of available seats for the class of service. |
<Status>006</Status> |
End of the BIC status. |
</BICStatus> |
End of the array. |
</BICStatusAry> |
End of the Booking Indicator Code availability. |
</BICAvail> |
|
... |