Wednesday, November 25, 2009

WCF Client

Visual Studio .NET 2008 provides a GUI interface for "Add Service Reference", which calls to svcutil.exe under the covers.

I created a new Windows Console project in VS.NET 2008 and right clicked on the project and selected "Add Service Reference", and was presented with the following dialog:

This generated the Client Proxy necessary to consume the Service. It actually created a new folder under my project called "Service References", and beneath that, an additional folder for each Service Reference.

Here is the client code that uses the generated proxy.

using System;
using WCFClient.ServiceReference;

namespace WCFClient
public class Client
public static void Main(string[] args)
GreetingServiceClient serviceClient = new GreetingServiceClient();
Console.Write(serviceClient.GetGreeting("Philip", "Tenn"));

My thoughts on this:

  • Really like being able to choose the namespace of the generated client proxy.

  • Creating the client code itself was simple ... just construct an instance of the GreetingServiceClient, and call the methods as if they were any regular class method. The details are hidden under the covers of WCF.

No comments:

Post a Comment