Click here to Skip to main content
15,346,809 members
Articles / Programming Languages / Visual Basic
Posted 16 Aug 2006


26 bookmarked

Windows Communication Foundation (WCF) Service Client

Rate me:
Please Sign up or sign in to vote.
2.52/5 (13 votes)
16 Aug 20062 min read
An article on using a WCF Service in a client application.

Image 1


WCF (Windows Communication Foundation) is a great framework for developing service oriented applications. This article explains the steps needed to use a WCF service from a client application.


The best starter guide for WCF I could find was this. It guides you step-by-step to create a WCF service and a client application. However, the steps needed to create the client application and call the methods exposed by the service did not sound so handy. The article says that before the client application can use the service, we should run svcutil.exe to generate the proxy classes. These proxy classes are then used to access the methods exposed by the service.

There must be a better option. This article explains how to add a Web Reference to a WCF service in a client application.

Using the code

Create a WCF service as per the steps explained in the Hello World sample. If you do not want to create the service from scratch, you can download the WCF Service attached with this article.

Once you have the service ready, compile and run it. You will see the console window open up. At this stage, the service is ready, and client applications can call methods exposed by the service.

Most of you who have worked with .NET web services would certainly agree with me that Web References are the easiest way to invoke a web service. I was trying to do the same with the WCF service. However, I saw that the Service Discovery Operation failed to recognize the service because Metadata Publishing is not enabled.

The following configuration settings show how to enable Metadata Publishing on a WCF service:

<?xml version="1.0" encoding="utf-8" ?> 
   <service name="HelloService.HelloService" 
       behaviorConfiguration="HelloService.HelloService" />
    <behavior name="HelloService.HelloService" >
     <serviceMetadata httpGetEnabled="true" />

The above configuration settings will enable Metadata Publishing on the service.

Now, let us create a client application which accesses the HelloService. Either create an application from scratch, or you could use the WCF Client attached with this article.

Follow the steps below to create a client application:

  1. Create a VB.NET Console Application (or C# if you prefer it).
  2. Add a Web Reference to the service with the following URL: http://localhost/hello (or the correct URL if you have modified the default service location).

The following code shows how to access the WCF service exposed by the server:

Dim o As New HelloService.HelloService
System.Console.WriteLine("Response from WCF Service: {0}", o.sayHi())

Points of Interest

The example above shows how easy it is to access a WCF service. The client application can simply add a Web Reference to the service, and can use it just like any one would do with an ASP.NET web service.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

No Biography provided

Comments and Discussions

GeneralThank you very much! Pin
petervanekeren6-Sep-12 5:00
Memberpetervanekeren6-Sep-12 5:00 
GeneralBuilding a web service client with WCF Pin
Shameer Kunjumohamed17-Oct-10 6:37
MemberShameer Kunjumohamed17-Oct-10 6:37 
GeneralThanks Pin
Kevin Whitefoot17-May-10 21:40
MemberKevin Whitefoot17-May-10 21:40 
Just what I needed!
Generalinteractive window station under non-system account Pin
masaniparesh29-Nov-07 4:04
Membermasaniparesh29-Nov-07 4:04 
Generalclient in c++ Pin
chemita_cpu7-Sep-07 1:01
Memberchemita_cpu7-Sep-07 1:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.