Sending Proxy Server Credentials in .NET

In .NET, a new proxy object can be created to include the authentication credentials required to access the Galileo Web Services via the proxy server. This proxy class is then sent with each call to the Galileo Web Services.

  1. Create new proxy classes for each service.

  2. Import the proxy class into the Web Services project.

  3. For each call to the Galileo Web Services, add references to the URL, port, and authentication parameters for the proxy server. The security and authentication credentials must be explicitly included in each call to a service. The following code provides sample calls to the Galileo Web Services in VB.NET and C#.

VB.NETSample Proxy Server Credentials

The following code provides a sample of proxy credentials sent with a call to the Galileo Web Services. See VB.NET Sample Calls for examples of requests with proxy server credentials.
 

Make the call to the Galileo Web Services.

Public Function doAvail(ByVal xmlRequest As XmlDocument, ByValxmlFilter As XmlDocument) As XmlElement

 

Dim xws As XmlSelectWebService = New XmlSelectWebService()

Create and set up the credentials for the Web Service. The namespaces for respective Web Services are XMLSelectWebService, BookingWebService, FlightInformationWebService, and EncodeDecodeWebService.

User name and password are assigned by Galileo.

The Travel Codes Translator eBL does not require authentication. The other services require Basic Authentication, however, Windows XP defaults to Digest Authentication.

Dim UserName As String = "UnitTest"

Dim Password As String = "UnitTest"

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

Dim cc As CredentialCache = New CredentialCache()

cc.Add(New Uri(xws.Url), "Basic", credentials)

xws.Credentials = cc

Set up a WebProxy to get through the firewall, if necessary.

Dim wp As WebProxy = New WebProxy()

URL of the proxy server. Confirm that the appropriate port is included.

wp.Address = New Uri("http://yourproxy.company.com:80") 'This is the name of your proxy

 

wp.BypassProxyOnLocal = True

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

wp.Credentials = New NetworkCredential("userID", "password", "proxyDomain")

 

xws.Proxy = wp

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

A Host Access Profile is required to access Galileo Web Services.

Dim xmlResponse As XmlElement = xws.SubmitXml("HostAccessProfile", xmlRequest.DocumentElement, xmlFilter.DocumentElement)

Return the response data as an XML element.

Return xmlResponse

 

End Function

Sample C# Proxy Server Credentials

The following code provides a sample of proxy credentials sent with a call to the Galileo Web Services. See C# Sample Calls for examples of including requests with proxy server credentials.
 

Make the call to the Galileo Web Services.

public XmlElement doAvail( XmlDocument xmlRequest, XmlDocumentxmlFilter)

 

{

Create and set up the credentials for the Web Service. The namespaces for respective Web Services are XMLSelectWebService, BookingWebService, FlightInformationWebService, and EncodeDecodeWebService.

User name and password are assigned by Galileo.

The Travel Codes Translator eBL does not require authentication. The other services require Basic Authentication, however, Windows XP defaults to Digest Authentication.

XmlSelectWebService xws = new XmlSelectWebService();

string UserName = "UserName";

string Password = "Password";

NetworkCredential credentials = new NewtworkCredential (UserName, Password);

CredentialCache cc = new CredentialCache();

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

xws.Credentials = cc;

Set up a WebProxy to get through the firewall, if necessary.

WebProxy wp = new WebProxy();

URL of the proxy server. Confirm that the appropriate port is included.

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");

 

xws.Proxy = wp;

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

A Host Access Profile is required to access the Galileo Web Services.

XmlElement xmlResponse = xws.SubmitXml("HostAccessProfile", xmlRequest.DocumentElement, xmlFilter.DocumentElement);

Return the response data as an XML element.

return xmlResponse;

 

}