Categories : Article, Dot Net Development
The dotnet technology offers two important sources for creating web services under .NET framework. They are WCF and ASP.NET Web API. Selecting from the two can be a bit confusing thing for many developers especially the beginners. This article focuses on few important distinguishable features of the two technologies which can be helpful to the developers for selection of an appropriate technology to create web services while developing web applications using ASP.NET.
- A brief Introduction about WCF & ASP.NET Web API:
Talking about WCF, it is a useful .NET programming model usually used for development of service based applications. With WCF as a base, it is possible to develop secure and reliable web applications which can easily adopt to various platforms. WCF allows inter communication of the applications in a distributed environment. As compared to WCF, ASP.NET Web API is a .NET framework that helps in development of HTTP services which can reach out to clients over various devices, browsers, thereby enabling the wider reach of the web applications. This is an ideal technology for development of RESTful applications in .NET.
Unlike ASP.NET Web API that supports only HTTP & HTTPS protocols, WCF supports number of transport protocols like HTTP, TCP, UDP, Named Pipes and various other custom transport protocols and also allows switching between these protocols. Hence, web services built using WCF programming model during ASP.NET development can be accessible across different transports. So, it’s not wrong to say that if you are willing to develop secure and reliable web services for access across variety of transports then opting for WCF will be a good option. On other hand, ASP.NET Web API will be good in case you want to develop HTTP services for applications that are accessible from a wide variety of clients or devices.
- Message Exchange Pattern:
WCF supports request-response, one way and even duplex message exchange patterns while on other hand ASP.NET Web API offers support for request-response or one way service operations only. However in order to support additional message exchange patterns through Web API, SignalR and WebSockets integration is required.
Security is at best with WCF technology as it supports development of web services using best standards like Reliable Messaging, Transactions, and Message Security. Compared to WCF, ASP.NET Web API supports only the basic level protocols and not the high level ones like Reliable Messaging, Transactions etc., and therefore it is less secure than WCF. So, if you are developing applications in ASP.NET with security as main concern then opting for WCF is a good option.
WCF is faster than ASP.NET Web API and allows for ASP.NET application development much quickly.
When compared to Web API, WCF offers better exception handling mechanism to the developers through FaultContract. Unhandled exceptions return as SOAP faults in Web API which is not the case with WCF. So, if you want to develop services for your application with reliable exception handling mechanism included, then go for using WCF technology.
[Total: 3 Average: 4.3/5]