First WCF Service Application – WCF Tutorial

In this blog, I will be creating a WCF service application project. If you want to learn WCF from the beginning, please read my earlier blog.

Let’s create the first WCF Service Application

To create a WCF project open Visual Studio 2012 and select File->New Project.

Click on WCF from an installed template (Left area)

In the above screen, you can see 4 types of WCF project that can be created. But there is confusion between WCF Service Library and WCF Service Application.
You may find the difference between these 2.

WCF Service Library:
A project for creating a host-independent WCF service class library (.dll).
WCF Service Application:
A project for creating a WCF service application that is hosted in IIS/WAS.  Once you choose the WCF service application, an svc file automatically added to your project solution but not in the WCF service library.
So let’s start our first program in WCF by choosing the WCF service application as I will be creating IIS hosted service.
Once you create this project, your solution will look like this:

How to test WCF service
To test WCF service you may use WCFTESTCLIENT.
To use this client, open Visual Studio command prompt, and type wcftestclient
wcf service application
Below window will open.
wcf service application
Right-click on “My Service Project” and select Add service, below box will appear. Type your service URL and press ok.
wcf service application
wcf service application
To test your operation click on the name of operation from the left side area.
Then provide input/parameters in the right side area and click on Invoke to see the output.
wcf service application
Generating proxy class
SVCUTIL.EXE: As per the Microsoft statement, SVCUTIL is a Service Model Metadata Utility Tool. It is used to generate the proxy class.
Basic syntax to generate proxy class using SVCUTIL is
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:59314/Service1.svc
To run above command you need Visual Studio Command Prompt.
wcf service application svcutil
Once you generate the proxy and config files, you may check these files at a given location.
App.config will look like this:
<?xml version=”1.0″ encoding=”utf-8″?>
                <binding name=”BasicHttpBinding_IService1″ />
            <endpoint address=”http://localhost:59314/Service1.svc” binding=”basicHttpBinding”
                bindingConfiguration=”BasicHttpBinding_IService1″ contract=”IService1″
                name=”BasicHttpBinding_IService1″ />
And the Proxy class will expose all variables operations which were mentioned in the WCF application.
Please follow and like us:

2 thoughts on “First WCF Service Application – WCF Tutorial”

Leave a Comment