The following example shows how to create a simple application that interfaces with the XML Select Web Service to request an air availability. In this example, the application is written in C# and the Web Services toolkit is VisualStudio.NET. However, any Web Services-compatible development environments can be used.
In the Web Services toolkit, create a new project named XWSSample.
In C#, create a Windows Application project.
Create a new Form.
In the Form, create the following fields:
A Submit button.
Two small textboxes named tbUser and tbPassword.
A large text box: tbResponse. Set the Multiline property to TRUE, and maximize the text box to fill most of the dialog box.
Add a web reference for the XML Select Web Service.
In VS.NET, right-click on References and select Add Web Reference.
In VS.NET, adding a web reference automatically downloads the WSDL to your development environment and creates a SOAP proxy to the Web Service.
Enter the address for the XML Select Web Service: http://testws.galileo.com/XmlSelect/XmlSelect.asmx
When prompted, enter the user name and password, which will be provided by your Apollo or Galileo representative.
If prompted to enter the user name and password again, enter the same values and leave the domain blank.
The web page for the service displays. The left pane on this page provides a brief overview of the service interface.
In VS.NET, the reference displays as WebReference1 in the Solution Explorer. The reference can be expanded to display the WSDL file that was imported from the XML Select Web Services site.
Create an OnClick event for the Submit button.
In VS.NET, double-click the Submit button to add an OnClick event.
At the top of the code, add the following lines:
using
System.Xml;
using System.Net;
In the OnClick event code,
located at the bottom of the file, enter the following lines:
(For easier copying, see the code
without annotations.)
Makes the XML transaction request for air availability (AirAvailabilty_6_2) |
XmlDocument xmlRequest = new XmlDocument(); xmlRequest.LoadXml("<AirAvailability_6_2> |
Specifies an unfiltered transaction response. |
XmlDocument xmlFilter = new XmlDocument(); xmlFilter.LoadXml("<_></_>"); |
Specifies the Web Service and associated proxy. |
WebReference1.XMLSelectWebService xws = new WebReference1.XMLSelectWebService(); |
Provides the user identification (network credentials). Note: For Windows XP Professional, a CredentialCache object for basic authentication may be required. |
xws.Credentials
= new System.Net.NetworkCredential( |
Requests an XML response from the Web Service for the Simulator Host Access Profile. (Profiles are provided by Galileo). xmlRequest and xmlFilter specifies the Document (root) XML element for the request and filter. |
XmlElement
xmlResponse = xws.SubmitXml("Simulator", |
Sets the response as an XML text string. |
tbResponse.Text = xmlResponse.OuterXml; |
Compile and run the application.
In VS.NET, press F5.
When prompted, enter the user name and password again.
Click Submit. The response displays in the tbResponse text box.