C# Sample 5:
Retrieving Itinerary Data
In this example (the sample is using ASP.NET web service clients not WCF), a confirmation number (record locator) is used to retrieve an itinerary (PNR/BF) booked in Sample 2. Detail from the itinerary is then be extracted for display to the traveler. This example uses Itinerary eBL, which allows the itinerary detail to be retrieved in one call to the CRS.
-
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/Itinerary?WSDL. -
A sample of a proxy created by VisualStudio.NET is available in the Sample Site.
-
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.
-
Create a function, ItineraryController, which formats an XML template, retrieves the required data from the Reservation Builder eBL 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 required namespaces. |
using System; |
using System.Net; |
|
using System.XML; |
|
using System.Collections; |
|
using System.Text; |
|
namespace
|
|
|
|
|
{ |
Declares the ItineraryController class, which manages the Itinerary eBL request. |
public class ItineraryController |
{ |
|
|
|
public ItineraryController() |
|
No constructor logic is required. |
{ |
} |
|
Retrieves an XML document containing the specified Confirmation Number (Record Locator). |
public XmlNode DoRetrieveItinerary( XmlDocument requestDOM) |
|
{ |
Gets a web service proxy from the factory. |
GwsItinerary Iws = new GwsItinerary(); |
Creates
and sets up the credentials for Itinerary eBL. Itinerary eBL uses Basic Authentication, however, Windows XP defaults to Digest Authentication. |
string UserName = "UserName"; |
string Password = "Password"; |
|
NetworkCredential
credentials |
|
CredentialCache cc = new CredentialCache(); |
|
cc.Add(new Uri(Iws.Url), "Basic", credentials); |
|
Iws.Credentials = cc; |
|
Sets up a WebProxy to get through the firewall, if necessary. URL of the proxy server. Confirm that the appropriate port is included. |
WebProxy wp = new WebProxy(); |
wp.Address = new Uri("http://yourproxy.company.com:80"); |
|
|
wp.BypassProxyOnLocal = true; |
The User ID, password, and domain for the proxy server. |
wp.Credentials
= new NetworkCredential("userID","password", |
|
Iws.Proxy = wp; |
Specifies the Document (root) XML element for the request and filter. There are no methods associated with Itinerary eBL. A Host Access Profile is required to access Itinerary eBL. |
XmlElement responseElement = Iws.Itinerary( "HostAccessProfile", null, requestDOM.DocumentElement); |
Returns the response data as an XML element. |
return responseElement; |
|
} |
|
|
Reads the Booking response and display the itinerary booked. |
public XmlDocument CreateRequest(XmlNode xmlBookingResponse) |
|
{ |
Creates an XML document. |
XmlDocument doc = new XmlDocument(); |
Sets up the namespace. |
XmlNamespaceManager mgr = new XmlNamespaceManager(new NameTable()); |
|
mgr.AddNamespace("gi", "http://ns.galileo.com"); |
Retrieves the
|
XmlNode recloc = xmlBookingResponse.SelectSingleNode("//gi:Success/gi:PnrID/gi:RecordLocator", mgr); |
|
|
Creates a buffer for the responses. |
StringBuilder req = new StringBuilder(); |
Makes the RetrieveTrip request. The types of itinerary data can be specified for the response. |
req.Append("<RetrieveTrip_RQ "); |
Returns a description of the passenger's air segment, if available. |
req.Append("AdditionalAirSegmentInfo='1' "); |
Returns |
req.Append("AdditionalCarSegmentInfo='1' "); |
Returns a description of the passenger's hotel segment, if available. |
req.Append("AdditionalHotelSegmentInfo='1' "); |
Returns a description of the passenger's W3 segment, if available. |
req.Append("AdditionalW3SegmentInfo='0' "); |
Decode any information in the response that was requested to be encoded. Note: This request does not decode in place. A decode node is appended to the end of the document that contains codes and their human language equivalents. |
req.Append("DecodeItems='1' "); |
Displays the passenger's complete itinerary in the response. Applies only when a customer supplies a session ID. |
req.Append("DisplayItinerary='0' "); |
|
req.Append(">"); |
Primary traveler's confirmation number. |
req.AppendFormat("<RecordLocator>{0}</RecordLocator>", GetText(recloc, ".")); |
Ends the itinerary information and the confirmation number profile. |
req.Append("</RetrieveTrip_RQ>"); |
|
doc.LoadXml(req.ToString()); |
|
return doc; |
|
} |
|
|
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(XmlNode inNode, string xPath) |
{ |
|
XmlNode tempNode = inNode.SelectSingleNode(xPath); |
|
if (tempNode==null) |
|
return ""; |
|
return tempNode.InnerText; |
|
|
} |
|
} |
|
} |
-
The Apollo or Galileo CRS returns the following data in a response.
Begins the Itinerary eBL response. |
<RetrieveTrip_RS Version="1.0.200303102232" xmlns="http://ns.galileo.com"> |
Begins the description of the results of the request. |
<Travel> |
Begins the passenger description for the PNR/BF. |
<PassengerInformation> |
Begins the list of passengers in the PNR/BF. |
<Passengers> |
Lists the passenger's first and last name. The number is the passenger's location in the PNR/BF. (Typically, a maximum of four passengers are allowed per PNR/BF.) |
<Passenger FirstName="PAM" Number="1" Surname="TEST" /> |
</Passengers> |
|
The primary passenger's contact information. The telephone number attribute can have formatting characters (e.g., hyphens or periods). The <PhoneLocationType>
attribute indicates the type of telephone number: The <CityAbbr> attribute
is a reference only field for travel agents. There is no cross-validation
with the phone area code. This element indicates only |
<Telephones> |
<Telephone CityAbbr="DEN" PhoneLocationType="R" PhoneNumber="000-303-1234561" /> |
|
</Telephones> |
|
The primary passenger's address and is a required field. The <DeliveryAddress> indicates the address where the itinerary information is sent. This field is also required, even if it is the same as the primary address. |
<Addresses> |
<Address>PAM TEST¤5350 S VALENCIA WAY¤GREENWOOD VILLAGE COLORADOZ/80111</Address> |
|
<DeliveryAddress>PAM TEST¤5350 S VALENCIA WAY¤GREENWOOD VILLAGE COLORADOZ/80111</DeliveryAddress> |
|
</Addresses> |
|
Ends passenger description. |
</PassengerInformation> |
Begins the description of the flight segment of the itinerary. |
<FlightItems> |
The first flight segment in the itinerary. |
<FlightItem SegmentNumber="1"> |
Lists all or some of the following details for the flight segment, including:
|
<FlightDetails ArrivalDateTime="2003-06-12T15:14:00-00:00" ChangeOfGauge="N" DepartureDateTime="2003-06-12T11:50:00-00:00" FlightFlown="N" FlightNumber="6339" MarriageNumber="" OperationalSuffix="" SellType="L" StopOverIgnore="" TicketlessIndicator="Y"> |
<MarketingAirline>US</MarketingAirline> |
|
<DepartureAirport LocationCode="DEN" /> |
|
<ArrivalAirport LocationCode="ORD" /> |
|
<FlightSegment> |
|
<BookingClass> |
|
<Booked NumSeats="1" ResBookDesigCode="Y" Status="HK" /> |
|
</BookingClass> |
|
</FlightSegment> |
|
</FlightDetails> |
|
<FlightServiceDetails> |
|
<FlightData DepartureDate="0000-00-00" FlightNumber="" NumberOfLegs="" OperationalSuffix="" Status=""> |
|
<MarketingAirline /> |
|
</FlightData> |
|
</FlightServiceDetails> |
|
<SeatAssignment> |
|
<Seat Number="" Passenger="TEST/PAM" Status="PN" /> |
|
</SeatAssignment> |
|
Ends the description of the flight segment of the itinerary. |
</FlightItem> |
|
</FlightItems> |
Details all the information that was encoded in the request and what the values are when decoded by Travel Codes Translator eBL. |
<Decode> |
|
<Airport CityCode="DEN" CityName="Denver" Code="DEN" CountryCode="US" StateProvinceCode="CO">Denver Intl Arpt</Airport> |
|
<Airport CityCode="CHI" CityName="Chicago" Code="ORD" CountryCode="US" StateProvinceCode="IL">O'Hare Intl Arpt</Airport> |
|
<AirlineSeatingClass Code="Y">Coach/Economy</AirlineSeatingClass> |
|
<Airline Code="US">US Airways</Airline> |
|
</Decode> |
Details any requested segments that were not a part of the primary passenger's itinerary. |
<Warnings> |
|
<Text>Requested Car Info, but the PNR did not contain any Car Segments</Text> |
|
<Text>Requested Hotel Info, but the PNR did not contain any Hotel Segments</Text> |
|
</Warnings> |
Ends the description of the results of the request. |
</Travel> |
Ends the Itinerary eBL response. |
</RetrieveTrip_RS> |