/** * CallService * Parms were already read. Now call the service proxy classes * */ void CallService() { if (SERVTYPE.ECHO == servtype) // Echo { if (0 == urlSuffix.Length) { urlSuffix = ECHO_CONTEXT; } EchoService echosv = new EchoService(); Console.WriteLine("CLIENT>> Connecting to Echo Service..."); echosv.Url = uriString + urlSuffix; Console.WriteLine("CLIENT>> Connected. Sending Echo Request to "+echosv.Url+"..."); try { echoStringInput echoParm = new echoStringInput(); echoParm.echoInput = msg; Console.WriteLine("CLIENT>> Sending message '"+ msg + "' ..."); echoStringResponse result = echosv.echoOperation(echoParm); Console.WriteLine("CLIENT>> The answer is '" + result.echoResponse + "'"); } catch (Exception e) { Console.WriteLine(">>>ECHO SERVICE EXCEPTION<<<\n" + e); } } else if (SERVTYPE.ASYNC == servtype) // Async Echo { if (0 == urlSuffix.Length) { urlSuffix = ECHO_CONTEXT; } // Instantiate the service, and create the service url EchoService echosv = new EchoService(); Console.WriteLine("CLIENT>> Connecting to Async Echo Service..."); echosv.Url = uriString + urlSuffix; Console.WriteLine("CLIENT>> Connected. Sending Echo Request to "+echosv.Url+"..."); try { // Create the argument object and IAsyncResult, then invoke Async echoStringInput echoParm = new echoStringInput(); echoParm.echoInput = msg; Console.WriteLine("CLIENT>> Sending Async message '" + msg + "' ..."); IAsyncResult ar = echosv.BeginechoOperation(echoParm, EchoCallback, echosv); int waiting = timeout; Thread.Sleep(1000); // Wait for completion while (!ar.IsCompleted) { if (waiting <= 0) { Console.WriteLine("CLIENT>> ERROR - Timeout waiting for reply."); break; } Console.WriteLine("CLIENT>> invocation still not complete"); Thread.Sleep(1000 * SLEEPER); waiting -= SLEEPER; } Console.WriteLine("CLIENT>> Async Invocation Complete"); } catch (Exception e) { Console.WriteLine(">>>ECHO SERVICE EXCEPTION<<<\n" + e); } } else // must be Ping { if (0 == urlSuffix.Length) { urlSuffix = PING_CONTEXT; } PingService pingsv = new PingService(); Console.WriteLine("CLIENT>> Connecting to Ping Service..."); pingsv.Url = uriString + urlSuffix; Console.WriteLine("CLIENT>> Connected. Sending Echo Request to "+pingsv.Url+"..."); try { pingStringInput pingParm = new pingStringInput(); pingParm.pingInput = msg; Console.WriteLine("CLIENT>> Sending message '"+ msg + "' ..."); pingsv.pingOperation(pingParm); Console.WriteLine("CLIENT>> Ping complete. Check server log to verify message delivery."); } catch (Exception e) { Console.WriteLine(">>>PING SERVICE EXCEPTION<<<\n" + e); } } }