Difference between WCF and Web API

What is WCF?

WCF stands for Windows Communication Foundation. It is used to create a distributed and interoperable Applications. WCF is an effective platform for developing service-oriented applications. It allows developers to create secure, reliable, and high profile development solutions which can be integrated across platforms and interoperate with existing investments.

In this tutorial, you will learn

What is Web API?

ASP.NET Web API is a framework which allows you to build HTTP services for browsers and mobile devices. It is an ideal platform for developing RESTful applications on the ASP .NET Framework.

The ASP.NET Web API is an extensible framework for building HTTP based services that can be accessed in different applications on different platforms such a web, windows, mobile devices, etc.

KEY DIFFERENCE

  • WCF offers request-reply, one-way, or duplex while Web API is by default request-reply only.
  • WCF is used for developing SOAP-based services whereas Web API is used for both SOAP-based and RESTful services.
  • WCF does not offer any support for MVC features whereas Web API supports MVC features.
  • WCF supports HTTP, UDP, and custom transport protocol whereas Web API supports only HTTP protocol.
  • WCF offers Text, MTOM, and Binary Encoding support whereas Web API supports the UTF-8 encoding format.
  • WCF supports message queues, message security, duplex communication, transaction whereas Web API doesn’t support.
  • WCF stands for Windows Communication Foundation whereas API stands for Application Program Interface.

Why use WCF?

Stack Overflow Questions ASP.net web API vs. WCF

Here, are pros/benefits of using WCF:

Why used Web API?

Google Trends WCF vs. ASP.Net web API

Here, are pros/benefits of using web API:

Characteristics of WCF

Characteristics of Web API

WCF Vs Web Service

Parameter WCF Web API
Message Exchange Pattern Request reply, one-way, or duplex. By default request-reply only. However, additional message pattern can be supported with web sockets integration.
Hosting IIS hosting, Self-hosting & works activation services. Self-hosting & IIS hosting.
Open Source It is not open source software. It is shipped with.Net framework.It is also available as an independent download.
Support for MVC features WCF does not provide any support for MVC features like controllers, routing, filter, auction results, etc. ASP.NET Web API supports MVC features like routing, controllers, results, filter, action, etc.
Encoding support Text, MTOM, and Binary. Default support for UTF-8 encoding format.
Support for Support for HTTP, UDP, and custom transport protocol. Supports only HTTP protocol
Use of model User attributed based programming model. Maps HTTP verbs to methods
Configuration Uses web.config and attributes to configure a HttpConfiguration class but not on the web.config Service. Web API can be configured using web.config service.
RESTful services It offers supports for RESTFUL service but with limitations. Ideal for building RESTFUL services.

The deciding factor for WCF vs. Web API

Following is a quick checklist to help to determine whether to use WCF or Web API

Scenario WCF 4.5 ASP.NET Web API
Requires support for scenarios like Message queues, end to end message security, duplex communication, distributed transactions, etc. Select Do NOT Select

When you already have existing working WCF services and Wants to add HTTP support additionally. Select Do NOT Select

One code base to provide support both SOAP and RESTful endpoints. Select Do NOT Select

Wants to create a resource-oriented service over HTTP. Do NOT Select Select

Your project is an MVC application and wants some functionality over HTTP. Do NOT Select Select

You want to build only an HTTP / RESTful services Do NOT Select Select

 

YOU MIGHT LIKE: