1.

Compare WCF vs ASP.NET Web API and state the differences with advantages and disadvantages?

Answer»

Windows Communication Foundation is designed to exchange standard SOAP-based messages using a variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ, etc. WCF i.e. Windows Communication Foundation is a framework used for building Service Oriented applications (SOA) and supports multiple transport protocols like HTTP, TCP, MSMQ, etc. WCF ships out with the .NET Framework. WCF service is good for Message Queue, duplex communication, one-way messaging. WCF supports SOAP and XML formats. 

ASP.NET API is a framework for building non-SOAP based services over HTTP only.  Web API is a Framework to build HTTP Services that can reach a board of clients, including browsers, mobile, IoT Devices, etc. and PROVIDED an ideal platform for building RESTful applications. It is LIMITED to HTTP based services. ASP.NET framework ships out with the .NET framework and is Open Source. One major advantage of Web API is that it is the best fit with MVC PATTERN. Web API supports any media format including JSON, XML. 

  • Both Web API and WCF can be self-hosted or can be hosted on the IIS Server.  


WCF
WebAPI
1PROTOCOL
Multiple protocol support (like HTTP, TCP, Named Pipes and more)
Supports only HTTP protocol

Format
SOAP is the default format. SOAP message has specific format. Supports SOAP and XML Format
Web API supports any media format including XML and JSON.

Size
Heavy weight because SOAP messages have more than just data
Light Weight because only required information is passed.

Principles
Follows WS-* specification
Follows REST Principles

CONFIGURATION
Need lot of configuration to run
Web API is simple and no configuration needed to run.

Service
WCF is good for developing service-oriented applications,
While ASP.Net Web API is perfect for building HTTP services. Web API is best fit with MVC pattern.


For each method there must be attributes like – “WebGet” and “WebInvoke”
Web API supports HTTP protocol verbs for communication.


For REST service we need to use attribute “WebInvoke”.
Unlike WCF Rest we can use the full features of HTTP in Web API


Discussion

No Comment Found