Hello Friends, In this tutorial, I am going to tell you what is WCF and the advantages of using it. WCF is a framework that can be used to create a service-oriented application.
After completing this tutorial you will be able to understand:
- What is WCF?
- Components of WCF.
- Advantages of WCF.
- Scenarios where WCF can be used?
WCF stands for Windows Communication Foundation. WCF is a programming model for building distributed application and interoperable application. A distributed application is one where the part of the application runs on two or more computer nodes. WCF is used to create a service-oriented application that can be used by multiple clients. WCF can be used to send asynchronous messages from one end point to another end point. The end point can be a client such as a browser, an iPhone, a tablet of a service that requests data from a service endpoint. WCF is used to create a service that is accessible to Windows, Linux or any other devices.
Scenarios where WCF can be used?
- A Secured service that needs to perform some business transaction.
- A Service that delivered some data to other application such as whether report.
- A Service that exchanges data between two or more peoples for communication.
- A service that needs to used by the browser as well as Mobile devices.
Fundamental Terms of WCF.
When we create a WCF Service it exposes a collection of EndPoints. This EndPoint is responsible for communication with Clients that is consuming the service. The EndPoint is the address which is used to send or received the message.
The EndPoint has the following major component:
The address is the location where your service is hosted as URL. This URL is used by the client to build communication between service and client. An example of Address is
The binding specifies the protocol that will use to build communication with the specified end point.
It specifies the functionality that the endpoint is going to expose. The contract contains the name of the Interface.
Below is the example of EndPoint:
A message is a communication unit which is sent and received from the client. It contains the body, headers and many other several parts.
If your Service was the human body, channels would be the sensory nerves of your Service. Sensory nerves carry messages from receptors in your body to your brain. Sensory messages pass through multiple nerves on the way to the brain.
Channels act as sensory nerves between the service and clients. It is used to carry messages between service and clients. There are two types of channel.
1- Transport Channel:
Transport Channel handles the communication over the wire. It transfers messages between service and client using Transport protocol. It supports protocols like TCP, HTTP, MCMQ.
2- Protocol Channel:
It is used to implement security to implement security, transaction and reliable messaging.
It specifies the hosting such as Self Hosting, IIS hosting, WAS Hosting and Windows Service Hosting.
It is the client application which is used to expose the service operations in form of method.
The metadata can be used to automatically generate and configure clients for accessing WCF services. We can enable the ServiceMetadata node inside the serviceBehavior node of the service configuration file.
Advantages of WCF Service:
- The main feature of WCF is interoperability
- It provides better security as compared to web service
- No need to make a big change for security.
- It is language independent.
- It is Location independent.
- WCF can control Concurrency issue.
Hope you understand this important tutorial about WCF in .NET and what is the advantages of it. I will appreciate your feedback, comments, and suggestions.
- Introduction to ASP.NET Web API.
- Factory Design Pattern in C#.
- Introduction to ASP.NET MVC Application Page Life Cycle.
- keep vs peek method in ASP.NET MVC.