Пример #1
0
        static void CallService()
        {
            TestProxy.DataServiceClient client = new TestProxy.DataServiceClient();

            try
            {
                Console.WriteLine(client.GetData());
            }
            finally
            {
                // Close the proxy
                client.Close();
            }
        }
Пример #2
0
        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();
            }
        }