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
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 the left side area.
Then provide input/parameters in the right side area and click on Invoke to see the output.
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.
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”
And the Proxy class will expose all variables operations which were mentioned in the WCF application.
In the next blog, I will write about the proxy class and how to use them.
Read this - What is Microservice Architecture?
Related blogs to WCF Service-
- Introduction to WCF
- ABC of WCF
- Basics of WCF Architecture
- WCF vs Web Service
- What is XML serialization?
- WCF Binding
- Create first WCF application
- Fault Contract in
- WCF Data Contract vs Message Contract
- Message Contract
- Data Contract Serialization and De-Serialization
- Data Contract in WCF
- Operation Contract in WCF
- Service Contract in WCF
- How to host a WCF service in IIS?
- WAS Hosting in WCF
- Self Hosting in WCF
- How to create WCF RESTful Service.
You may read some popular blogs on SharePointCafe.Net
Please follow and like us: