C# Sample 4:
Decoding Vendor Codes

This example takes encoded air vendor names from the air availability response in Sample 1, and decodes them into human language using Travel Codes Translator eBL.

  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/TravelCodesTranslator?WSDL
    .

  2. Create a function, TranslateController, 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 required namespaces.

using System;

using System.Net;

using System.XML;

using System.Collections;

using System.Text;

namespace GettingStarted

 

 

 

{

Declares the TranslateController class, which manages the Travel Codes Translator eBL request.

public class TranslateController

{

 

public  TranslateController()

No constructor logic is required.

{

}

Select the first air segment from a valid air availability response. Use a DOM to create the request.

public XmlNode doTranslateRequest(XmlDocument DOMRequest)

 

{

Gets a web service proxy from the factory.

TravelCodesTranslator TTws = new TravelCodesTranslator();

Creates and sets up the credentials for Travel Codes Translator eBL. The user name and password are assigned by Galileo.

Travel Codes Translator eBL uses Basic Authentication, however, Windows XP defaults to Digest Authentication.

string UserName = "UserName";

string Password = "Password";

NetworkCredential(UserName,Password);

CredentialCache cc = new CredentialCache();

cc.Add(new Uri(TTws.Url), "Basic", credentials);

TTws.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","proxyDomain");

 

TTws.Proxy = wp;

Specifies the Document (root) XML element for the request and filter. This example uses the Decode method to translate CRS- and industry-specific codes into human language suitable for display to travelers.

Note: A  Host Access Profile (HAP) is not required because this Web Service does not transact with the CRS.

XmlElement responseElement =
TTws.Decode(DOMRequest.DocumentElement);

Returns the response data as an XML element.

return responseElement;

 

}

 

 

Creates the request document from the air availability.

public XmlDocument CreateRequest(XmlElement xmlAirAvail)

{

 

XmlDocument doc = new XmlDocument();

Builds a hash table for the requests.

Hashtable decodeHash = new Hashtable();

Gets the air vendor codes from the AirAvailability_6_2 response.

XmlNodeList airVendorNodes = xmlAirAvail.SelectNodes("//AirV");

 

for (int i=0;i<airVendorNodes.Count;++i)

 

{

 

if (!decodeHash.ContainsKey(airVendorNodes[i].InnerText))decodeHash.Add(airVendorNodes[i].InnerText, "Airline");

 

}

Creates a buffer for the translations.

StringBuilder req = new StringBuilder();

Makes the Travel Codes Translator eBL request to Decode.

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

 

for (IDictionaryEnumerator e = decodeHash.GetEnumerator();e.MoveNext();)

 

{

 

req.AppendFormat("<{0} Code='{1}' />", e.Value, e.Key);

 

}

 

req.Append("</Decode>");

 

doc.LoadXml(req.ToString());

 

return doc;

 

}

 

}

 

}

 

  1. The Apollo or Galileo CRS returns the following data in a response.

Travel Codes Translator eBL decode response.

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

Lists the translation for each air vendor code listed in the request.

<Airline Code="AA">American</Airline>

<Airline Code="BD">bmi british</Airline>

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

<Airline Code="US">US Airways</Airline>

Ends the Travel Codes Translator eBL response.

</Decode>