static void CallService() { TestProxy.DataServiceClient client = new TestProxy.DataServiceClient(); try { Console.WriteLine(client.GetData()); } finally { // Close the proxy client.Close(); } }
static void CallServiceWithExceptionHandling() { TestProxy.DataServiceClient client = new TestProxy.DataServiceClient(); try { // Making calls Console.WriteLine(client.GetData()); // Close the proxy client.Close(); } catch (TimeoutException timeEx) { client.Abort(); } catch (FaultException faultEx) { client.Abort(); } catch (CommunicationException commProblem) { client.Abort(); } }