Shakespeare Insult client app (3/3)

This is blog 3 of 3. This blog will learn how to create an app that consumes your web service.

Quick steps

  1. In Visual Studio, create a new Console application.
  2. Add a service reference to the project.
  3. In code, use the ServiceSoapClient to call the available web services (methods).
2. using the web services

3. Example code

static void Main(string[] args)
{
    try
    {
        ServiceSoapClient client = new ServiceSoapClient();

        string insult = client.GetInsult();
        Console.WriteLine(insult);
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message.ToString());
    }
    Console.WriteLine("Press any key to continue");
    Console.ReadKey();
}

That was fun! Let’s do it again.