Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            GreetingServiceClient client = null;
            try
            {
                client = new GreetingServiceClient();

                client.Open();

                var name = NameTextBox.Text;
                var greeting = client.Greet(name);

                MessageBox.Show(greeting);

                client.Close();
            }
            catch (EndpointNotFoundException epnfe)
            {
                throw;
            }
            catch (CommunicationException ce)
            {
                if (client != null) client.Abort();
                throw;
            }
        }
		private static void UseSoap(string endpoint)
		{
			using (var client = new GreetingServiceClient(endpoint))
			{
				string response = client.Greet("Tony");
				Console.WriteLine(response);
			}
		}