In this blog i will be creating a WCF service application project.
So let's follow these steps to do this.
To create a WCF project open Visual Studio 2012 and select File->New Project.
Click on WCF from installed template (Left area)
In above screen you can see 4 types of WCF project can be created. But there are confusion between WCF Service Library and WCF Service Application.
You may find difference between these 2.
WCF Service Library:
A project for creating a host-independent WCF service class librarary (.dll).
WCF Service Application:
A project for creating WCF service application that is hosted in IIS/WAS. Once you choose WCF service application, a svc file automatically added to your project solution but not in WCF service library.
So let’s start our first program in WCF by choosing 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
Below window will open.
Right click on “My Service Project” and select Add service, below box will appear. Type your service url and press ok.
To test your operation click on the name of operation from left side area.
Then provide input/parameters in right side area and click on Invoke to see the output.
Generating proxy class
SVCUTIL.EXE: As per Microsoft statement, SVCUTIL is a Service Model Metadata Utility Tool. It is used to generate 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.
Once you generate the proxy and config files, you may check these filese at 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"
And Proxy class will expose all variables operations which were mentioned in WCF application.
In next blog i will explain about proxy class and how to use them.