8 Sample VisualStudio/.NET/C# Client

The Web Service Interfaces may be accessed from a .NET client program by using Microsoft VisualStudio® to create C# language bindings from the WSDL:

In VisualStudio®, create (for example) a consoled application

Add a Service Reference, and enter the IO web service endpoint URL (see “Accessing WSDL” (page 16))

Enter a service name (e.g., “IOService”) as the Namespace valueAdd these namespaces:

using System.Net;

using System.Net.Security; using System.Xml;

Add this code:

try

{

//Open the config file to set the timestamp token and username token XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

//Get the configuration node XmlNode appSettingsNode =

xmlDoc.SelectSingleNode("configuration"); //get the service model node

XmlNode servicemodelNode = appSettingsNode.LastChild; //Get the client node

XmlNode clientNode = servicemodelNode.LastChild; //get the endpoint node

XmlNode endpointNode = clientNode.LastChild; //get the headers node

XmlNode headersNode = endpointNode.LastChild; //get the security node

81