Who Is The Winner - Web API or WCF

At the end you will know the result for who is the winner and who is the loser. So, let's starts the race.

As you know their are lots of technologies available that allow you to create services which can be consumed by different client, the client can be web application, window application, mobile application, etc. Services can be http enabled or support multiple protocols.

As you know today we will discuss only about the WCF and Web API.

WCF stands for Windows Communication Foundation, created by Microsoft with .NET Framework 3.0. It provides us a platform where we can build secure, reliable service that can integrate across the platforms and interoperate smoothly.

Web API is also a framework that is used to make HTTP services. As you know, now a days we are using mobiles, tablets, apps and different types of services, so Web API is a simple and reliable platform to create HTTP enabled services that can reach wide range of clients. It is used to create complete REST services.

Web API or WCF

So, let's start the race between Web API and WCF and see at the last that who is the winner.

SOAP

Simple Object Access Protocol [SOAP] is a protocol invented by Microsoft that is used to create a structured format data or message that can transfer over the internet. SOAP protocol is the main foundation of WCF and uses XML format. Web Service creates WSDL [Web Services Description Language] file which provides the information about the service data, so WSDL file is used by the client to understand the methods available on the service.

REST

REST stands for Representational State Transfer. It is not a protocol like SOAP whether it is architecture design pattern that is used for building and creating Web Services.

Web API used this pattern to build web services. Basically Web API is a resource driven architecture that exposes endpoint to the client. Web API is fully REST supported. It uses GET, PUT, POST, DELETE verbs to communicate with the clients.

Interoperability

RESTful services like Web API are simple and light weight and easy to access by any client which supports HTTP calls. It is not like to SOAP where client need to understand WSDL to implement the service.

WSDL uses some extra configuration and require some additional logic that might not be available on many devices such as phones, smart TVs, Tablets, etc.

As WCF supports many protocol so it can consumed by lots of client that are using different protocol such as TCP, MSMQ, etc. not only HTTP protocol to access service.

Interoperability

Configuration Overhead

Client needs to make more configurations as compared to Web API to access WCF Service. WCF uses more configurations such as endpoints, behaviors, etc to expose the service. But Web API has more standard way to customize the service which helps it to reach more clients.

Speed

As RESTful services use HTTP protocol to access client and HTTP request/response are smaller than a SOAP request, so Web API is the best choice if you are going to create a service for low bandwidth devices or mobile devices to access client. HTTP request/response is also more readable as compared to SOAP because it contains header, body, etc. which makes it complex.

Security

WCF service provides us high level security framework which provide enterprise level security. It uses WS-I standard to provide secure service.

But Web API uses web standard security such as basic authentication, token authentication and for more complex such as OAuth; Web API provides more flexibility. Then use SOAP when you are going to authenticate with external services such as google, facebook, etc.

WCF or Web API

Winner?

So, finally to see the above point, we cannot decide which is better than the other. But I want to focus on the two points. Firstly, if you are going to create a service which would be used on different platforms, then go with WCF. Secondly, if you are creating internet service which is going to use external resource, then go with Web API.


Similar Articles