Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Secure Web Services via TCP/IP

, 30 May 2003
Describes an approach for delivery of Soap Messages serialised using ASP.NET Web Client Services over TCP/IP
wsaltroute2.zip
ArgosAPIExtensions
Bin
Client
ArgosAPIExtensions.dll
WSAltRouteTest.exe
WSIPTransports.dll
Server
WebServices
WSAltRouteArgos
bin
ArgosAPIExtensions.dll
ArgosAPIExtensions.pdb
WSAltRouteArgos.dll
WSAltRouteArgos.pdb
Global.asax
WSAltRouteArgos.csproj.webinfo
WSAltRouteArgos.vsdisco
WSAltRouteBEFake.exe
WSAltRouteTest
App.ico
Web References
ArgosTrinketService
Reference.map
Service1.disco
Service1.wsdl
WSAltRouteBEFake
App.ico
WSAltTransports2
WSQTransports.dll
AsyncHelper.dll
using System;
using System.Configuration;						// For Configuration file access
using System.Collections.Specialized;			// For specialised collections
using System.IO;
using System.Net;
using System.Threading;
using System.Xml;								// For XML construction of default SOAP message for proxy failure
using System.Text;								// StringBuilder


// --------------------------------------------------------------------------------
// Namespace:   WSAltRouteTest
// Author:      SGregory
// Date:        02 January 2003
// Description: Encapsulates Test harness  
// --------------------------------------------------------------------------------
namespace WSAltRouteTest
{
	using AsyncHelper;		// Helper object for any async work
	using WSAltRouteProxy;
	using WSAltTransports;


	/// <summary>WSAltRouteTest.ConsoleDriver</summary>
    /// <author>SGregory</author>
    /// <date>02 January 2003</date>
    /// <remarks>Main class to drive the tests</remarks>
    class ConsoleDriver
	{
		// Delegates for async return functions
		protected delegate byte[] ReturnImageEventHandler();
		protected delegate void SendImageEventHandler(byte[] vbytImage);
		protected delegate string[] HellowWorldArrEventHandler(string vstrName);


		/// <summary>WSAltRouteTest.ConsoleDriver.Wrapper</summary>
        /// <author>SGregory</author>
        /// <date>17 January 2003</date>
        /// <remarks>Class containing helper methods called by main()</remarks>
        internal class Wrapper
		{
            /// <summary>WSAltRouteTest.ConsoleDriver.Wrapper.Wrapper</summary>
            /// <author>Simon G</author>
            /// <date>26 February 2003</date>
            /// <remarks>Constructor</remarks>
            /// <param name="vblnIncludeStackTraceOnException" type="bool">Flag insicating if stacktrace should be dumped by client during exception logging</param>
            /// <param name="vblnEnableHTTPCalls" type="bool">If true, then make HTTP based calls</param>
            /// <param name="vblnEnableMSMQCalls" type="bool">If true, then make MSMQ based calls</param>
            /// <param name="vblnEnableMQCalls" type="bool">If true, then make MQ based calls</param>
			/// <param name="vblnEnableIPCalls" type="bool">If true, then make IP based calls</param>
            /// <param name="vstrLocationOfImages" type="string">Folder for reading and writing images</param>
            /// <postconditions>Wrapper created and primed</postconditions>
            internal Wrapper(
				bool vblnIncludeStackTraceOnException,
				bool vblnEnableHTTPCalls,
				bool vblnEnableMSMQCalls,
				bool vblnEnableMQCalls,
				bool vblnEnableIPCalls,
				string vstrLocationOfImages)
			{
				// Store flags
				m_blnIncludeStackTraceOnException = vblnIncludeStackTraceOnException;
				m_blnEnableHTTPCalls = vblnEnableHTTPCalls;
				m_blnEnableMSMQCalls = vblnEnableMSMQCalls;
				m_blnEnableMQCalls = vblnEnableMQCalls;
				m_blnEnableIPCalls = vblnEnableIPCalls;
				m_strLocationOfImages = vstrLocationOfImages;
				if (m_strLocationOfImages.EndsWith("\\") == false)
					m_strLocationOfImages += "\\";
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldThing</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldThing(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				// Delegate...
				DoHelloWorldThing(
					vstrURI, 
					vintTimeoutInSecs, 
					string.Empty);
			}
			

			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldThing</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldThing(
				string vstrURI,
				int vintTimeoutInSecs,
				string vstrResponseUrl)
			{
				localhost.Service1 objHelloWorldService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
				if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
				if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
				if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// If we get here we'll make the call...

				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhost.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// Could set up an alternative return Queue other than <queue>_resp
					objHelloWorldService.ResponseUrl = objHelloWorldService.FormatCustomUri(vstrResponseUrl);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;
					// Run the method and print out the return
					TSLog(objHelloWorldService.HelloWorld("Simon"));
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
												"DoHelloWorldThing", 
												objHelloWorldService.Url, 
												e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldThingWSE</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldThingWSE(
				string vstrURI,
				int vintTimeoutInSecs,
				string vstrResponseUrl)
			{
				localhostWSE.Service1 objHelloWorldService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhostWSE.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// Could set up an alternative return Queue other than <queue>_resp
					if (vstrResponseUrl.Length > 0)
						objHelloWorldService.ResponseUrl = objHelloWorldService.FormatCustomUri(vstrResponseUrl);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;

					// Augment request context with WSE goodies
					// This includes:
					//
					//	* Time-to-live of 60s
					//	* User name and password credentials
					//	* Encryption and Signing
					ProxyCommonWSE.SetupSOAPRequestContext(objHelloWorldService.RequestSoapContext);

					// Run the method and print out the return
					TSLog(objHelloWorldService.HelloWorld("Simon"));

					// Verify that a SOAP request was received, with valid credentials
					// and a signature
					ProxyCommonWSE.ValidateCredentials(objHelloWorldService.ResponseSoapContext);
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoHelloWorldThingWSE", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldArrThing</summary>
			/// <author>Cheese</author>
			/// <date>11 January 2003</date>
			/// <remarks>Does the aray version of HelloWorld</remarks>
			/// <param name="vstrURI" type="string">URI</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldArrThing(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhost.Service1 objHelloWorldService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhost.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;
					// Run the method and print out the return
					string strFinalRes = string.Empty;
					string[] arrRes = objHelloWorldService.HelloWorldArr("Simon");
					foreach(string strRes in arrRes)
					{
						strFinalRes += strRes + " ";
					}
					TSLog(strFinalRes.Trim());
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoHelloWorldArrThing", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldArrThingWSE</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldArrThingWSE(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				// Delegate...
				DoHelloWorldArrThingWSE(
					vstrURI,
					vintTimeoutInSecs,
					null);
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldArrThingWSE</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldArrThingWSE(
				string vstrURI,
				int vintTimeoutInSecs,
				string vstrResponseUrl)
			{
				localhostWSE.Service1 objHelloWorldService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhostWSE.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// Could set up an alternative return Queue other than <queue>_resp
					objHelloWorldService.ResponseUrl = objHelloWorldService.FormatCustomUri(vstrResponseUrl);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;

					// Augment request context with WSE goodies
					// This includes:
					//
					//	* Time-to-live of 60s
					//	* User name and password credentials
					//	* Encryption and Signing
					ProxyCommonWSE.SetupSOAPRequestContext(objHelloWorldService.RequestSoapContext);

					// Run the method and print out the return
					string strFinalRes = string.Empty;
					string[] arrRes = objHelloWorldService.HelloWorldArr("Simon");
					foreach(string strRes in arrRes)
					{
						strFinalRes += strRes + " ";
					}
					TSLog(strFinalRes.Trim());
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoHelloWorldArrThingWSE", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldArrThingWSENoCtx</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldArrThingWSENoCtx(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhostWSE.Service1 objHelloWorldService = null;
				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd);

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhostWSE.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// Could set up an alternative return Queue other than <queue>_resp
					// objHelloWorldService.ResponseUrl = objHelloWorldService.FormatCustomUri(vstrURI + "_Rispy");
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;

					// DON'T Augment request context with WSE goodies
					// Just do the path action for routing when we are dealign with MSMQ or MQ.
					if (strScheme != "http")
						ProxyCommonWSE.SetupSOAPRequestContextWithRoutePathAction(objHelloWorldService.RequestSoapContext);
					else
						ProxyCommonWSE.SetupSOAPRequestContext(objHelloWorldService.RequestSoapContext);

					// Run the method and print out the return
					string strFinalRes = string.Empty;
					string[] arrRes = objHelloWorldService.HelloWorldArr("Simon");
					foreach(string strRes in arrRes)
					{
						strFinalRes += strRes + " ";
					}
					TSLog(strFinalRes.Trim());
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoHelloWorldArrThingWSENoCtx", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoSendImageThing</summary>
			/// <author>Cheese</author>
			/// <date>11 January 2003</date>
			/// <remarks>Send an Image as array of bytes</remarks>
			/// <param name="vstrURI" type="string">URI</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoSendImageThing(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhost.Service1 objHelloWorldService = null;
				byte[] bytImage = null;
				FileStream fs = null;
				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd).ToUpper();

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// Read a file
				try
				{
					fs = new FileStream(m_strLocationOfImages + "CD.gif", FileMode.Open, FileAccess.Read, FileShare.Read);
					bytImage = new byte[fs.Length];
					fs.Read(bytImage, 0, bytImage.Length);
				}
				catch(Exception e)
				{
					// See if there is an associated Status code
					string strWebExcpStatus = string.Empty;
					if (e is System.Net.WebException)
						strWebExcpStatus = "[" + ((System.Net.WebException)e).Status.ToString() + "]";
					TSLog("Exception [Type=" + e.GetType().ToString() + "]" + strWebExcpStatus + " caught in DoSendImageThing while loading file: " + e.Message + e.StackTrace);
					return;
				}
				finally
				{
					if (fs != null)
						fs.Close();
				}

				// Do the send
				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhost.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;
					// Run the method and print out the return
					objHelloWorldService.SendImage(bytImage);
					TSLog("Sent Image Data (see " + m_strLocationOfImages + "SendImage" + strScheme + ".gif)");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoSendImageThing", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoSendImageThingWSE</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Sends an Image, against the given endpoint usign WSE</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoSendImageThingWSE(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhostWSE.Service1 objHelloWorldService = null;
				byte[] bytImage = null;
				FileStream fs = null;
				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd).ToUpper();

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// Read a file
				try
				{
					fs = new FileStream(m_strLocationOfImages + "CD.gif", FileMode.Open, FileAccess.Read, FileShare.Read);
					bytImage = new byte[fs.Length];
					fs.Read(bytImage, 0, bytImage.Length);
				}
				catch(Exception e)
				{
					// See if there is an associated Status code
					string strWebExcpStatus = string.Empty;
					if (e is System.Net.WebException)
						strWebExcpStatus = "[" + ((System.Net.WebException)e).Status.ToString() + "]";
					TSLog("Exception [Type=" + e.GetType().ToString() + "]" + strWebExcpStatus + " caught in DoSendImageThingWSE while loading file: " + e.Message + e.StackTrace);
					return;
				}
				finally
				{
					if (fs != null)
						fs.Close();
				}

				// Do the send
				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhostWSE.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;

					// Augment request context with WSE goodies
					// This includes:
					//
					//	* Time-to-live of 60s
					//	* User name and password credentials
					//	* Encryption and Signing
					ProxyCommonWSE.SetupSOAPRequestContext(objHelloWorldService.RequestSoapContext);

					// Run the method and print out the return
					objHelloWorldService.SendImage(bytImage);
					TSLog("Sent Image Data (see " + m_strLocationOfImages + "SendImage" + strScheme + " {WSE}.gif)");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoSendImageThingWSE", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoSendImageThingViaDIMEWSE</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Sends an Image, against the given endpoint usign WSE's DIME capability</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoSendImageThingViaDIMEWSE(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhostWSE.Service1 objHelloWorldService = null;
				FileStream fs = null;
				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd).ToUpper();

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// Read a file
				try
				{
					fs = new FileStream(m_strLocationOfImages + "CD.gif", FileMode.Open, FileAccess.Read, FileShare.Read);
				}
				catch(Exception e)
				{
					// See if there is an associated Status code
					string strWebExcpStatus = string.Empty;
					if (e is System.Net.WebException)
						strWebExcpStatus = "[" + ((System.Net.WebException)e).Status.ToString() + "]";

					TSLog("Exception [Type=" + e.GetType().ToString() + "]" + strWebExcpStatus + " caught in DoSendImageThingWSE while loading file: " + e.Message + e.StackTrace);
					return;
				}

				// Do the send
				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhostWSE.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;

					// Augment request context with WSE goodies
					// This includes:
					//
					//	* Time-to-live of 60s
					//	* User name and password credentials
					//	* Encryption and Signing
					ProxyCommonWSE.SetupSOAPRequestContext(
						objHelloWorldService.RequestSoapContext,
						fs);

					// Run the method and print out the return
					objHelloWorldService.SendImageAsDIMEAttachment();
					TSLog("Sent DIME Image Data (see " + m_strLocationOfImages + "SendDIMEImage" + strScheme + " {WSE}.gif)");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoSendImageThingViaDIMEWSE", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
				finally
				{
					// Close the file we opened
					if (fs != null)
						fs.Close();
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoReceiveImageThing</summary>
			/// <author>Cheese</author>
			/// <date>12 January 2003</date>
			/// <remarks>Drive the ReceiveImage processing via a variety of ways</remarks>
			/// <param name="vstrURI" type="string">URI endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeour</param>
			internal void DoReceiveImageThing(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhost.Service1 objHelloWorldService = null;
				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd).ToUpper();

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// Do the receive
				try
				{
					// Create the Service proxy
					objHelloWorldService = new localhost.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;
					// Run the method and print out the return
					byte[] bytImage = objHelloWorldService.ReturnImage();
					FileStream fs = new FileStream(m_strLocationOfImages + "ReturnImage" + strScheme + ".gif", FileMode.Create);
					fs.Write(bytImage, 0, bytImage.Length);
					fs.Close();
					TSLog("Received Image Data [" + bytImage.Length + " bytes] (see " + m_strLocationOfImages + "ReturnImage" + strScheme + ".gif)");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoReceiveImageThing", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			// Async methods

			/// <summary>WSAltRouteTest.ConsoleDriver.Wrapper.DoSendImageThingAsync</summary>
			/// <author>SGregory</author>
			/// <date>13 January 2003</date>
			/// <remarks>Async version of send image</remarks>
			/// <param name="vstrURI" type="string">URI</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoSendImageThingAsync(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhost.Service1 objHelloWorldService = null;
				byte[] bytImage = null;
				FileStream fs = null;

				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd).ToUpper();

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// Read a file
				try
				{
					fs = new FileStream(m_strLocationOfImages + "CD.gif", FileMode.Open, FileAccess.Read, FileShare.Read);
					bytImage = new byte[fs.Length];
					fs.Read(bytImage, 0, bytImage.Length);
				}
				catch(Exception e)
				{
					// See if there is an associated Status code
					string strWebExcpStatus = string.Empty;
					if (e is System.Net.WebException)
						strWebExcpStatus = "[" + ((System.Net.WebException)e).Status.ToString() + "]";

					TSLog("Exception [Type=" + e.GetType().ToString() + "]" + strWebExcpStatus + " caught in DoSendImageThingAsync while loading file: " + e.Message + e.StackTrace);
					return;
				}
				finally
				{
					if (fs != null)
						fs.Close();
				}

				// Do the send
				try
				{
					if (m_ssiSendImage != null)
						throw new ApplicationException("Async request already in progress.");

					// Create the Service proxy
					objHelloWorldService = new localhost.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;
					// Run the method and print out the return - use the Async Helper class
					//IAsyncResult ar = objHelloWorldService.BeginSendImage(new AsyncCallback(ReturnImageCallback), objHelloWorldService);
					m_ssiSendImage = new Asynchronizer(new AsyncCallback(this.SendImageCallback), objHelloWorldService);
					IAsyncResult ar = m_ssiSendImage.BeginInvoke(
						new SendImageEventHandler(objHelloWorldService.SendImage), new object[] { bytImage } );
					ar.AsyncWaitHandle.WaitOne(objHelloWorldService.Timeout + 1000, true);
					m_ssiSendImage = null;
					if (((AsynchronizerResult)ar).MethodReturnedException == true)
						throw ((AsynchronizerResult)ar).ReturnedException;
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoSendImageThingAsync", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
					m_ssiSendImage = null;
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.Wrapper.DoReceiveImageThingAsync</summary>
            /// <author>SGregory</author>
            /// <date>13 January 2003</date>
            /// <remarks>Async version of receive image</remarks>
            /// <param name="vstrURI" type="string">URI</param>
            /// <param name="vintTimeoutInSecs" type="int">Timeout</param>
            internal void DoReceiveImageThingAsync(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhost.Service1 objHelloWorldService = null;
				string strScheme = vstrURI;
				int iIdxSchemeEnd = vstrURI.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrURI.Substring(0, iIdxSchemeEnd).ToUpper();

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// Do the receive
				try
				{
					if (m_ssiReturnImage != null)
						throw new ApplicationException("Async request already in progress.");

					// Create the Service proxy
					objHelloWorldService = new localhost.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;
					// Run the method and print out the return - use the Async Helper class
					//IAsyncResult ar = objHelloWorldService.BeginReturnImage(new AsyncCallback(ReturnImageCallback), objHelloWorldService);
					m_ssiReturnImage = new Asynchronizer(new AsyncCallback(this.ReturnImageCallback), objHelloWorldService);
					IAsyncResult ar = m_ssiReturnImage.BeginInvoke(
						new ReturnImageEventHandler(objHelloWorldService.ReturnImage), null);
					ar.AsyncWaitHandle.WaitOne(objHelloWorldService.Timeout + 1000, true);
					m_ssiReturnImage = null;
					if (((AsynchronizerResult)ar).MethodReturnedException == true)
						throw ((AsynchronizerResult)ar).ReturnedException;
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoReceiveImageThingAsync", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
					m_ssiReturnImage = null;
				}
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoHelloWorldArrThingWSEAsync</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes the HelloWorld processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoHelloWorldArrThingWSEAsync(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				localhostWSE.Service1 objHelloWorldService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					if (m_ssiHelloWorldArr != null)
						throw new ApplicationException("Async request already in progress.");

					// Create the Service proxy
					objHelloWorldService = new localhostWSE.Service1();
					// Set up the URI
					objHelloWorldService.Url = objHelloWorldService.FormatCustomUri(vstrURI);
					// Could set up an alternative return Queue other than <queue>_resp
					// objHelloWorldService.ResponseUrl = objHelloWorldService.FormatCustomUri(vstrURI + "_Rispy");
					// And the timeout
					objHelloWorldService.Timeout = vintTimeoutInSecs * 1000;

					// Augment request context with WSE goodies
					// This includes:
					//
					//	* Time-to-live of 60s
					//	* User name and password credentials
					//	* Encryption and Signing
					ProxyCommonWSE.SetupSOAPRequestContext(objHelloWorldService.RequestSoapContext);

					//IAsyncResult ar = objHelloWorldService.BeginReturnImage(new AsyncCallback(ReturnImageCallback), objHelloWorldService);
					m_ssiHelloWorldArr = new Asynchronizer(new AsyncCallback(this.HelloWorldArrWSECallback), objHelloWorldService);
					IAsyncResult ar = m_ssiHelloWorldArr.BeginInvoke(
						new HellowWorldArrEventHandler(objHelloWorldService.HelloWorldArr), new object[] { "Simon" });
					ar.AsyncWaitHandle.WaitOne(objHelloWorldService.Timeout + 1000, true);
					m_ssiHelloWorldArr = null;
					if (((AsynchronizerResult)ar).MethodReturnedException == true)
						throw ((AsynchronizerResult)ar).ReturnedException;
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoHelloWorldArrThingWSEAsync", 
						objHelloWorldService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}



			// Callbacks for asynchronous behaviour

			protected void SendImageCallback(
				IAsyncResult ar)
			{
				localhost.Service1 objHelloWorldService = (localhost.Service1)ar.AsyncState;
				string strScheme = objHelloWorldService.Url;
				int iIdxSchemeEnd = objHelloWorldService.Url.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = objHelloWorldService.Url.Substring(0, iIdxSchemeEnd).ToUpper();

				m_ssiSendImage = null;
				AsynchronizerResult asr = (AsynchronizerResult) ar;
				asr.SynchronizeInvoke.EndInvoke(ar);
				TSLog("Sent ASYNC Image Data (see " + m_strLocationOfImages + "SendImage" + strScheme + ".gif)");
			}

			protected void ReturnImageCallback(
				IAsyncResult ar)
			{
				localhost.Service1 objHelloWorldService = (localhost.Service1)ar.AsyncState;
				string strScheme = objHelloWorldService.Url;
				int iIdxSchemeEnd = objHelloWorldService.Url.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = objHelloWorldService.Url.Substring(0, iIdxSchemeEnd).ToUpper();

				m_ssiReturnImage = null;
				AsynchronizerResult asr = (AsynchronizerResult) ar;
				byte[] bytImage = (byte[])asr.SynchronizeInvoke.EndInvoke(ar);
				FileStream fs = new FileStream(m_strLocationOfImages + "ReturnImage" + strScheme + "Async.gif", FileMode.Create);
				fs.Write(bytImage, 0, bytImage.Length);
				fs.Close();
				TSLog("Received ASYNC Image Data [" + bytImage.Length + " bytes] (see " + m_strLocationOfImages + "ReturnImage" + strScheme + "Async.gif)");
			}

			protected void HelloWorldArrWSECallback(
				IAsyncResult ar)
			{
				localhostWSE.Service1 objHelloWorldService = (localhostWSE.Service1)ar.AsyncState;
				m_ssiHelloWorldArr = null;
				AsynchronizerResult asr = (AsynchronizerResult) ar;
				string[] arrRes = (string[])asr.SynchronizeInvoke.EndInvoke(ar);
				
				// Print out the return
				string strFinalRes = string.Empty;
				foreach(string strRes in arrRes)
				{
					strFinalRes += strRes + " ";
				}
				TSLog("Received ASYNC " + strFinalRes.Trim());
			}


			/// <summary>WSAltRouteTest.ConsoleDriver.DoMyColourThang</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes our own Colour Service processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			internal void DoMyColourThang(
				string vstrURI,
				int vintTimeoutInSecs)
			{
				WSAltRouteTest.localhost.Service1 objColourService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					// Create a Colour Service proxy
					objColourService = new WSAltRouteTest.localhost.Service1();
					objColourService.Timeout = vintTimeoutInSecs * 1000;

					// Set up URI
					objColourService.Url = objColourService.FormatCustomUri(vstrURI);

					// Ask service to Create a new colour skeleton
					WSAltRouteTest.localhost.Colour1[] arrCol = objColourService.ReturnColours(5);

					TSLog(arrCol.Length + " colours were returned - first code is " + arrCol[0].code + ".");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoMyColourThang", 
						objColourService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}



			/// <summary>WSAltRouteTest.ConsoleDriver.DoOurProductThang</summary>
			/// <author>SGregory</author>
			/// <date>02 January 2003</date>
			/// <remarks>Invokes James' Products processing, against the given endpoint</remarks>
			/// <param name="vstrURI" type="string">Endpoint</param>
			/// <param name="vintTimeoutInSecs" type="int">Timeout</param>
			/// <param name="vstrResponseUrl" type="string">Response Uri</param>
			internal void DoOurProductThang(
				string vstrURI,
				int vintTimeoutInSecs,
				string vstrResponseUrl)
			{
				WSAltRouteTest.localhostProd.ProductServiceService objProdService = null;
				string strScheme = string.Empty;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				try
				{
					// Create a Colour Service proxy
					objProdService = new WSAltRouteTest.localhostProd.ProductServiceService();
					objProdService.Timeout = vintTimeoutInSecs * 1000;

					// Set up URI
					objProdService.Url = objProdService.FormatCustomUri(vstrURI);

					// Also set up a return Uri
					objProdService.ResponseUrl = objProdService.FormatCustomUri(vstrResponseUrl);

					// We can calculate the scheme from this
					strScheme = objProdService.Url;
					int iIdxSchemeEnd = objProdService.Url.IndexOf("://");
					if (iIdxSchemeEnd > 0)
						strScheme = objProdService.Url.Substring(0, iIdxSchemeEnd);

//					// DON'T Augment request context with WSE goodies
//					// Just do the path action for routing when we are dealign with MSMQ or MQ.
//					if (strScheme == "msmq" ||
//						strScheme == "mq")
//						ProxyCommonWSE.SetupSOAPRequestContextWithRoutePathAction(objProdService.RequestSoapContext);
//					else
//						ProxyCommonWSE.SetupSOAPRequestContext(objProdService.RequestSoapContext);


					// Run the API a little

					//	1) Create a couple of new Products
					WSAltRouteTest.localhostProd.Product newProd = null;
					WSAltRouteTest.localhostProd.Product newProd2 = null;

					try
					{
						// New Product #1
						newProd = new WSAltRouteTest.localhostProd.Product();
						newProd.productId = "NEWPROD#5";
						newProd.description = "A new product - 5th one";
						newProd.active = true;
						newProd.category1 = "Category A5";
						newProd.category2 = "Category B5";
						newProd.category3 = "Category C5";
						newProd.category4 = "Category D5";
						newProd.category5 = "Category E5";
						newProd.purchasePrice = new Decimal(75);
						newProd.salesPrice = new Decimal(85);
						objProdService.createProduct(newProd);
						TSLog("Added new product with ID " + newProd.productId);
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-createProduct", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					try
					{
						// New Product #2
						newProd2 = new WSAltRouteTest.localhostProd.Product();
						newProd2.productId = "NEWPROD#6";
						newProd2.description = "Another new product - 6th one";
						newProd2.active = false;
						newProd2.category1 = "Category A6";
						newProd2.category2 = "Category B6";
						newProd2.category3 = "Category C6";
						newProd2.category4 = "Category D6";
						newProd2.category5 = "Category E6";
						newProd2.purchasePrice = new Decimal(23);
						newProd2.salesPrice = new Decimal(38.5);
						objProdService.createProduct(newProd2);
						TSLog("Added new product with ID " + newProd2.productId);
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-createProduct", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					// 2) Add some daily's - new ProductDaily's
					WSAltRouteTest.localhostProd.ProductDaily newProdDaily = null;

					DateTime dtNow = DateTime.Now;
					// For Product#1 - 8 daily's
					for (int iLast7Days = 7; iLast7Days >= 0; iLast7Days--)
					{
						TimeSpan tsSubDays = new TimeSpan(iLast7Days, 0, 0, 0);
						try
						{
							newProdDaily = new WSAltRouteTest.localhostProd.ProductDaily();
							newProdDaily.productId = newProd.productId;
							newProdDaily.date = dtNow.Subtract(tsSubDays);
							newProdDaily.availability = new Decimal((7 - iLast7Days) * 2);
							newProdDaily.sales = new Decimal(iLast7Days * 3);
							newProdDaily.stock = new Decimal(7 - iLast7Days);
							objProdService.createProductDaily(newProdDaily);
							TSLog("Added new product daily (" + newProdDaily.date + ") for product with ID " + newProd.productId);
						}
						catch(Exception e)
						{
							// Build me a string for writing
							string strConsoleLine = BuildConsoleLineForException(
								"DoOurProductThang-createProductDaily", 
								objProdService.Url, 
								e);

							// Write to Console
							TSLog(strConsoleLine);
						}
					}

					// For Product#2 - 5 daily's
					for (int iLast4Days = 4; iLast4Days >= 0; iLast4Days--)
					{
						TimeSpan tsSubDays = new TimeSpan(iLast4Days, 0, 0, 0);
						try
						{
							newProdDaily = new WSAltRouteTest.localhostProd.ProductDaily();
							newProdDaily.productId = newProd2.productId;
							newProdDaily.date = dtNow.Subtract(tsSubDays);
							newProdDaily.availability = new Decimal(iLast4Days);
							newProdDaily.sales = new Decimal(3 * iLast4Days);
							newProdDaily.stock = new Decimal(4 - iLast4Days);
							objProdService.createProductDaily(newProdDaily);
							TSLog("Added new product daily (" + newProdDaily.date + ") for product with ID " + newProd2.productId);
						}
						catch(Exception e)
						{
							// Build me a string for writing
							string strConsoleLine = BuildConsoleLineForException(
								"DoOurProductThang-createProductDaily", 
								objProdService.Url, 
								e);

							// Write to Console
							TSLog(strConsoleLine);
						}
					}

					//  3) updateProduct - change description and purchase price of Product#1
					try
					{
						newProd.description = "Updated " + newProd.description + " (made cheaper by 5)";
						newProd.purchasePrice = 40;
						objProdService.updateProduct(newProd);
						TSLog("Updated product description (" + newProd.description + ") for product with ID " + newProd.productId);
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-updateProduct", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					// 4) getProductDaily - all of Product#1
					WSAltRouteTest.localhostProd.ProductDaily[] prodDailys = null;
					try
					{
						prodDailys = objProdService.getProductDaily(newProd.productId);
						TSLog("Received " + prodDailys.Length + " product dailys for product with ID " + newProd.productId);
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-getProductDaily", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					// 5) updateProductDaily - alter info in Product#2's last daily - the stock was x 2
					try
					{
						newProdDaily.stock *= 2; 
						objProdService.updateProductDaily(newProdDaily);
						TSLog("Updated product daily (" + newProdDaily.date + ") for product with ID " + newProd2.productId);
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-updateProductDaily", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					//	6) Get Product#2 back in full
					WSAltRouteTest.localhostProd.Product checkProd = null;

					try
					{
						checkProd = objProdService.getProduct(newProd2.productId);
						TSLog("Fetched product details e.g. Cat1 (" + checkProd.category1 + ") for product with ID " + newProd2.productId);
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-getProduct", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					// 7) getAllProducts back
					WSAltRouteTest.localhostProd.Product[] colProds = null;

					try
					{
						colProds = objProdService.getAllProducts();

						for (int iIdx = 0; iIdx < colProds.Length; iIdx++)
						{
							string strProdId = colProds[iIdx].productId;
							string strCat1 = colProds[iIdx].category1;
							string strCat2 = colProds[iIdx].category2;
							string strCat3 = colProds[iIdx].category3;
							string strCat4 = colProds[iIdx].category4;
							string strCat5 = colProds[iIdx].category5;
							string strDesc = colProds[iIdx].description;
							Decimal decPurchasePrice = colProds[iIdx].purchasePrice;
							Decimal decSalesPrice = colProds[iIdx].salesPrice;
							bool blnIsActive = colProds[iIdx].active;
							blnIsActive = blnIsActive;
							TSLog("Fetched product details [" + strProdId + ", " + strDesc + ", " + decSalesPrice + "]");
						}
					}
					catch(Exception e)
					{
						// Build me a string for writing
						string strConsoleLine = BuildConsoleLineForException(
							"DoOurProductThang-getAllProducts", 
							objProdService.Url, 
							e);

						// Write to Console
						TSLog(strConsoleLine);
					}

					// Report completion
					TSLog("Our product test [" + strScheme + "] completed.");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoOurProductThang", 
						objProdService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}


			internal void DoOurArgosThing(
				string vstrURI,
				int vintTimeoutInSecs,
				bool vblnSerialize2Soap)
			{
				string strScheme = string.Empty;
				ArgosTrinketService.Service1 objTrinketService = null;

				// Check against flags
				if (m_blnEnableHTTPCalls == false &&
					vstrURI.IndexOf("http") == 0)
				{
					TSLog("Skipping HTTP call.");
					return;
				}
				else
					if (m_blnEnableMSMQCalls == false &&
					vstrURI.IndexOf("msmq") == 0)
				{
					TSLog("Skipping MSMQ call.");
					return;
				}
				else
					if (m_blnEnableMQCalls == false &&
					vstrURI.IndexOf("mq") == 0)
				{
					TSLog("Skipping MQ call.");
					return;
				}
				else
					if (m_blnEnableIPCalls == false &&
					vstrURI.IndexOf("ip") == 0)
				{
					TSLog("Skipping IP call.");
					return;
				}

				// If we get here we'll make the call...

				try
				{
					// Create the Service proxy
					objTrinketService = new ArgosTrinketService.Service1();
					// Set up the URI
					objTrinketService.Url = objTrinketService.FormatCustomUri(vstrURI);

					// We can calculate the scheme from this
					strScheme = objTrinketService.Url;
					int iIdxSchemeEnd = objTrinketService.Url.IndexOf("://");
					if (iIdxSchemeEnd > 0)
						strScheme = objTrinketService.Url.Substring(0, iIdxSchemeEnd);

					// And the timeout
					objTrinketService.Timeout = vintTimeoutInSecs * 1000;
					if (vblnSerialize2Soap)
						// Run the method and print out the return
						TSLog(objTrinketService.DoesTrinketExistInMySize(3));
					else
						// Run the method and print out the return
						TSLog(objTrinketService.DoesTrinketExistInMySize2(3));

					// Report completion
					TSLog("Our Argos test [" + strScheme + "] completed.");
				}
				catch(Exception e)
				{
					// Build me a string for writing
					string strConsoleLine = BuildConsoleLineForException(
						"DoOurArgosThing", 
						objTrinketService.Url, 
						e);

					// Write to Console
					TSLog(strConsoleLine);
				}
			}



			// Helpers

			/// <summary>WSAltRouteTest.ConsoleDriver.BuildConsoleLineForException</summary>
			/// <author>Simon G</author>
			/// <date>24 February 2003</date>
			/// <remarks>
			/// Given an exception, digs around a little to produce a standard string for
			/// display in a console etc.
			/// </remarks>
			/// <param name="vstrMethodName" type="string">Name of my method</param>
			/// <param name="vstrReqUrl" type="string">Request Url</param>
			/// <param name="e" type="System.Exception">Exception</param>
			/// <returns type="string">String for display</returns>
			private string BuildConsoleLineForException(
				string vstrMethodName, 
				string vstrReqUrl,
				Exception e)
			{
				// Capture any error and dump to console
				string strScheme = vstrReqUrl;
				int iIdxSchemeEnd = vstrReqUrl.IndexOf("://");
				if (iIdxSchemeEnd > 0)
					strScheme = vstrReqUrl.Substring(0, iIdxSchemeEnd);

				// See if there is an associated Status code
				string strWebExcpStatus = string.Empty;
				string strWebExcpProtocolStatus = string.Empty;
				if (e is System.Net.WebException)
				{
					strWebExcpStatus = "[" + ((System.Net.WebException)e).Status.ToString() + "]";
					if (((System.Net.WebException)e).Status == WebExceptionStatus.ProtocolError)
					{
						System.Net.WebResponse objResp = ((System.Net.WebException)e).Response;
						if (objResp is MSMQWebResponse)
							strWebExcpProtocolStatus = "[" + ((MSMQWebResponse)objResp).Status.ToString() + "]";
						else
							if (objResp is MQWebResponse)
							strWebExcpProtocolStatus = "[" + ((MQWebResponse)objResp).Status.ToString() + "]";
					}
				}

				// Finish constructing the line
				string strConsoleLine = "Exception [Type=" + e.GetType().ToString() + "]" + strWebExcpStatus + strWebExcpProtocolStatus + " caught in " + vstrMethodName + "[" + strScheme + "]: " + e.Message;
				if (m_blnIncludeStackTraceOnException == true)
					strConsoleLine += e.StackTrace;

				return strConsoleLine;
			}

			// Async result situation
			static private Asynchronizer m_ssiReturnImage = null;
			static private Asynchronizer m_ssiSendImage = null;
			static private Asynchronizer m_ssiHelloWorldArr = null;

			// Private data members
			bool m_blnIncludeStackTraceOnException = true;
			bool m_blnEnableHTTPCalls = true;
			bool m_blnEnableMSMQCalls = true;
			bool m_blnEnableMQCalls = true;
			bool m_blnEnableIPCalls = true;
			string m_strLocationOfImages = string.Empty;
		}


		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			TSLog("WSAltRouteTest process started [Soap over HTTP, MSMQ and MQ].");

			bool blnIncludeStackTraceOnException = true;
			bool blnEnableHTTPCalls = true;
			bool blnEnableMSMQCalls = true;
			bool blnEnableMQCalls = true;
			bool blnEnableIPCalls = true;
			string strHTTPUriNonWSE = string.Empty;
			string strHTTPUriWSE = string.Empty;
			string strMSMQRequestQ = string.Empty;
			string strMSMQResponseQ = string.Empty;
			string strMQRequestQ = string.Empty;
			string strMQResponseQ = string.Empty;
			string strIPUri = string.Empty;
			string strLocationOfImages = string.Empty;
			
			// Read configuration settings			
			NameValueCollection colSettings = ConfigurationSettings.AppSettings;

			// Set up the flags
			foreach (string strName in colSettings)
			{
				string[] arrVals = colSettings.GetValues(strName);
				if (strName.ToLower() == "notrace")
				{
					if (arrVals[0].ToLower() == "true")
						blnIncludeStackTraceOnException = false;
				}
				else
				if (strName.ToLower().IndexOf("enablehttpcalls") == 0)
				{
					if (arrVals[0].ToLower() == "false")
						blnEnableHTTPCalls = false;
				}
				else
				if (strName.ToLower().IndexOf("enablemsmqcalls") == 0)
				{
					if (arrVals[0].ToLower() == "false")
						blnEnableMSMQCalls = false;
				}
				else
				if (strName.ToLower().IndexOf("enablemqcalls") == 0)
				{
					if (arrVals[0].ToLower() == "false")
						blnEnableMQCalls = false;
				}
				else
					if (strName.ToLower().IndexOf("enableipcalls") == 0)
				{
					if (arrVals[0].ToLower() == "false")
						blnEnableIPCalls = false;
				}
				else
				if (strName.ToLower().IndexOf("msmqrequestq") == 0)
				{
					strMSMQRequestQ = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("msmqresponseq") == 0)
				{
					strMSMQResponseQ = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("mqrequestq") == 0)
				{
					strMQRequestQ = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("mqresponseq") == 0)
				{
					strMQResponseQ = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("httpurinonwse") == 0)
				{
					strHTTPUriNonWSE = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("httpuriwse") == 0)
				{
					strHTTPUriWSE = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("locationofimages") == 0)
				{
					strLocationOfImages = arrVals[0];
				}
				else
				if (strName.ToLower().IndexOf("ipuri") == 0)
				{
					strIPUri = arrVals[0];
				}
			}

			// Write up the settings
			string strFlags = string.Empty;
			if (blnEnableHTTPCalls == true)
				strFlags += "EnableHTTPCalls, ";
			if (blnEnableMSMQCalls == true)
				strFlags += "EnableMSMQCalls, ";
			if (blnEnableMQCalls == true)
				strFlags += "EnableMQCalls, ";
			if (blnEnableIPCalls == true)
				strFlags += "EnableIPCalls, ";

			if (strFlags.Length == 0)
			{
				TSLog(" *** You must enable at least one protocol!");
				Console.ReadLine();
				return;
			}
			TSLog("  Settings: " + strFlags.Substring(0, strFlags.Length-2));

			// Get our wrapper going, and pass the necessary flafs
			Wrapper objW = new Wrapper(
								blnIncludeStackTraceOnException,
								blnEnableHTTPCalls,
								blnEnableMSMQCalls,
								blnEnableMQCalls,
								blnEnableIPCalls,
								strLocationOfImages);

			// Do a dummy hello world thing - HTTP
			objW.DoHelloWorldThing(strHTTPUriNonWSE, 10);

			// Do a dummy hello world thing - MSMQ
			objW.DoHelloWorldThing(strMSMQRequestQ, 5);

			// Do same thing but use MQ as the transport
			objW.DoHelloWorldThing(strMQRequestQ, 7);

			// Do the same thing but using a named response queue
			objW.DoHelloWorldThing(strMQRequestQ, 7, strMQResponseQ);

			// Do the same thing but using an IP link
			objW.DoHelloWorldThing(strIPUri, 3);

			// Now try some more exotic things
			objW.DoHelloWorldArrThing(strHTTPUriNonWSE, 10);
			objW.DoHelloWorldArrThing(strMSMQRequestQ, 10);
			objW.DoHelloWorldArrThing(strMQRequestQ, 7);
			objW.DoHelloWorldArrThing(strIPUri, 3);

			// Now try even more exotic things
			objW.DoSendImageThing(strHTTPUriNonWSE, 10);
			objW.DoSendImageThing(strMSMQRequestQ, 10);
			objW.DoSendImageThing(strMQRequestQ, 7);
			objW.DoSendImageThing(strIPUri, 3);

			// Now try even more exotic things
			objW.DoReceiveImageThing(strHTTPUriNonWSE, 10);
			objW.DoReceiveImageThing(strMSMQRequestQ, 10);
			objW.DoReceiveImageThing(strMQRequestQ, 7);
			objW.DoReceiveImageThing(strIPUri, 3);

			// Do an Async version
			objW.DoSendImageThingAsync(strHTTPUriNonWSE, 10);
			objW.DoSendImageThingAsync(strMSMQRequestQ, 10);
			objW.DoSendImageThingAsync(strMQRequestQ, 7);
			objW.DoSendImageThingAsync(strIPUri, 3);

			objW.DoReceiveImageThingAsync(strHTTPUriNonWSE, 10);
			objW.DoReceiveImageThingAsync(strMSMQRequestQ, 10);
			objW.DoReceiveImageThingAsync(strMQRequestQ, 7);
			objW.DoReceiveImageThingAsync(strIPUri, 7);

			objW.DoMyColourThang(strHTTPUriNonWSE, 10);
			objW.DoMyColourThang(strMSMQRequestQ, 5);
			objW.DoMyColourThang(strMQRequestQ, 5);
			objW.DoMyColourThang(strIPUri, 3);

			// Do some WSE stuff
			objW.DoHelloWorldThingWSE(strHTTPUriWSE, 10, string.Empty);
			objW.DoHelloWorldThingWSE(strMSMQRequestQ, 5, string.Empty);
			objW.DoHelloWorldThingWSE(strMQRequestQ, 5, string.Empty);
			objW.DoHelloWorldThingWSE(strIPUri, 3, string.Empty);

			// Do some more WSE stuff
			objW.DoHelloWorldArrThingWSE(strHTTPUriWSE, 10);
			objW.DoHelloWorldArrThingWSE(strMSMQRequestQ, 5);
			objW.DoHelloWorldArrThingWSE(strMQRequestQ, 5);
			objW.DoHelloWorldArrThingWSE(strIPUri, 3);

			// Do the same WSE stuff but using named response queue
			objW.DoHelloWorldArrThingWSE(strMSMQRequestQ, 5, strMSMQResponseQ);
			objW.DoHelloWorldArrThingWSE(strMQRequestQ, 5, strMQResponseQ);

			// Do some more WSE stuff - async
			objW.DoHelloWorldArrThingWSEAsync(strHTTPUriWSE, 10);
			objW.DoHelloWorldArrThingWSEAsync(strMSMQRequestQ, 5);
			objW.DoHelloWorldArrThingWSEAsync(strMQRequestQ, 5);
			objW.DoHelloWorldArrThingWSEAsync(strIPUri, 5);

			// Now try even more exotic things with WSE
			objW.DoSendImageThingWSE(strHTTPUriWSE, 10);
			objW.DoSendImageThingWSE(strMSMQRequestQ, 10);
			objW.DoSendImageThingWSE(strMQRequestQ, 7);
			objW.DoSendImageThingWSE(strIPUri, 3);

			// Now send an image as a DIME attachment
			objW.DoSendImageThingViaDIMEWSE(strHTTPUriWSE, 10);
			objW.DoSendImageThingViaDIMEWSE(strMSMQRequestQ, 5);
			objW.DoSendImageThingViaDIMEWSE(strMQRequestQ, 5);
			objW.DoSendImageThingViaDIMEWSE(strIPUri, 3);

			// Now try using WSE but not setting up contexts (so should be like non-WSE)
			objW.DoHelloWorldArrThingWSENoCtx(strMSMQRequestQ, 10);
			objW.DoHelloWorldArrThingWSENoCtx(strMQRequestQ, 7);
			objW.DoHelloWorldArrThingWSENoCtx(strIPUri, 3);

			// JT Product access starts here! - to MQ and MSMQ only
			objW.DoOurProductThang(strMSMQRequestQ, 3, string.Empty);
			objW.DoOurProductThang(strMQRequestQ, 5, string.Empty);
			objW.DoOurProductThang(strIPUri, 3, string.Empty);

			// Do some special Argos stuff which can manipulate the Soap stream.
			// The first two calls uses raw Soap - the third uses a proprietary message-based format
			objW.DoOurArgosThing("http://localhost/WSAltRouteArgos/Service1.asmx", 3, true);
			objW.DoOurArgosThing(strIPUri, 3, true);
			objW.DoOurArgosThing(strIPUri, 3, false);

			// Signal done
			Thread.Sleep(100);
			TSLog("WSAltRouteTest process completed.");
			Console.ReadLine();
		}



		// Other helpers

		/// <summary>WSAltRouteBEFake.ConsoleDriver.TSLog</summary>
		/// <author>SGregory</author>
		/// <date>02 January 2003</date>
		/// <remarks>Logs to Console with a timestamp</remarks>
		static private void TSLog(
			string strMsg)
		{
			Console.WriteLine(DateTime.Now.ToString("dd MMM yyyy, HH:mm:ss") + ":  " + strMsg);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Simon Gregory
Web Developer
United Kingdom United Kingdom
I am the Technical Director for Myphones.com, which specialises in developing integrated VoIP products and services for the consumer and SME markets. Technology-wise, we are heavily into the 2nd generation WS stack atop .NET, and basically most things Microsoft, as well as C++ on Linux.

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 31 May 2003
Article Copyright 2003 by Simon Gregory
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid