VB.NET 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, TravelCodesController, which formats an XML template, retrieves the required data from the AirAvailability_6_2 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.

Imports System

Imports System.Xml

Imports System.Net

Imports System.Text

Imports System.Xml.XPath

 

Namespace GettingStarted

 

 

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

Public Class TravelCodeTranslatorController

 

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

Public Function doTranslateRequest(ByVal DOMRequest As XmlDocument) As XmlNode

Get a web service proxy from the factory.

Dim TTws As TravelCodesTranslator.
TravelCodesTranslator = New TravelCodesTranslator.
TravelCodesTranslator()

Create and set up the credentials for Flight Information eBL.  User name and password are assigned by Galileo.

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

Dim UserName As String = GWSConfig.UserName

Dim Password As String = GWSConfig.Password

Dim credentials As NetworkCredential = New NetworkCredential(UserName, Password)

Dim cc As CredentialCache = 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 your proxy server. Confirm that the appropriate port is included.

If Not GWSConfig.ProxyName.Equals("") Then

Dim wp As WebProxy = New WebProxy()

wp.Address = New Uri(GWSConfig.ProxyName)

wp.BypassProxyOnLocal = True

The User ID, password, and domain for the proxy server.

wp.Credentials = New NetworkCredential(GWSConfig.ProxyUsername, GWSConfig.ProxyPassword, GWSConfig.ProxyDomain)

TTws.Proxy = wp

 

End If

Specifies the Document (root) XML element for the request and filter. This example uses the Decode method.

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

Dim responseElement As XmlElement = TTws.Decode(DOMRequest.DocumentElement)

Returns the response data as an XML element.

Return responseElement

End Function

 

 

Creates the request document from the air availability.

Public Function CreateRequest(ByVal xmlAirAvail As XmlElement) As XmlDocument

Creates an XML Document.

Dim doc As XmlDocument = New XmlDocument()

Builds a hash table for the requests.

Dim decodeHash As Hashtable = New Hashtable()

Get the air vendor codes from the AirAvailability_6_2 response. Sets the vendor code as the key and the airline as the value.

Dim airVendorNodes As XmlNodeList = xmlAirAvail.SelectNodes("//AirV")

Dim i As Integer

For i = 0 To airVendorNodes.Count - 1

If (Not decodeHash.ContainsKey(airVendorNodes(i).InnerText)) Then decodeHash.Add(airVendorNodes(i).InnerText, "Airline")

 

End If

 

Next

Builds a list of the AirV codes to translate.

Dim req As StringBuilder = New StringBuilder()

 

 

Makes the Travel Codes Translator eBL request to Decode.

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

Retrieves the data from the hash table. Using the key prevents multiple instances of the same vendor code from being processed.

Dim de As DictionaryEntry

For Each de In decodeHash

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

 

Next

 

req.Append("</Decode>")

 

 

 

doc.LoadXml(req.ToString())

 

Return doc

 

End Function

 

 

 

End Class

 

End Namespace

 

  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>