Difference Between ASP.NET Web API and WCF

Introduction

This article describes the differences between the Web API and Windows Communication Foundation (WCF). And also describes how to choose between WCF and Web API.

What is the ASP. NET  Web API

The ASP. NET Web API is a framework that uses the HTTP services and makes it easy to provide the response to the client request. The response depends on the request of the clients. The Web API builds the HTTP services, and handles the request using the HTTP protocols. The request may be GET, POST, DELETE, PUT. We can also say that the ASP. NET Web API:

  • Is an HTTP service.
  • Is designed for reaching the broad range of clients.
  • Uses the HTTP application.

We use the ASP. NET Web API for creating the RESTtful  (Representational State Transfer) services.

The following are some important points of the ASP. NET Web API:

  • The ASP. NET Web API supports the MVC application features that are controller, media formatters, routing etcetera.
  • It is a platform for creating the REST services.
  • It is a framework for creating the HTTP services.
  • Responses can be formatted by the APIs MediaTypeFormatter into the Java Script Object Notation (JSON) and Extencible Markup Language (XML) formats.

Architecture of Web API

arch2.jpg

What the Windows Communication Foundation (WCF) is

WCF is also a framework but it creates a service-oriented application. It can send the data asynchronously from one endpoint service to another service. The endpoint service can be the part of the continuous available service that is hosted by the IIS. There are some important points of WCF:

  • WCF sends the data asynchronously.
  • It is a secure service to process the business transaction.
  • The message that is send can be a single character or a word sent as XML.
  • It includes the chat service that allows the two people for exchanging the data.

Architecture of WCF.

arch1.jpg

To choose between Web API and WCF:

  • You can choose the Web API when you want to create the service that uses all the HTTP features, such as request and response header, URIs, versioning etcetera.
  • You choose the Web API if you want to expose the HTTP services to a broad range of clients. These includes the mobile , iPhone and browsers.

Now define the reason of choosing the WCF:

  • You can choose the WCF  if you want to create the service that supports one-way messaging, message queues, duplex communication etcetera.
  • You can choose the WCF if you want to create a service that uses the fast transport channel, such as TCP, UDP, Named pipe etcetera.


Similar Articles