There have been a lot of debates lately on which technology to use when it comes to building web services for various client applications in the .NET world. Which one should we use, WCF or ASP.NET Web API?
Let us first describe the two technologies. WCF is a framework for building service-oriented applications on the .NET framework. ASP.NET Web API is a framework for building RESTful application on the .NET framework.
In my opinion, choosing between to the two technologies really depends on your needs. Consider the following before choosing which technology to use on your next .NET web services project.
Choose WCF if:
- Your service needs support for multiple transport protocols such as HTTP, TCP, UDP, and custom transports.
- Your service needs support for multiple encodings such as TEXT, MTOM, and Binary.
- You need to use WSDL to generate client proxies.
- Your service needs WS-* Standards such as Reliable Messaging, Transactions, and Message Security.
Choose ASP.NET Web API if:
- Your service is only HTTP based.
- Your service needs basic protocol and formats such as HTTP, Web Sockets, SSL, JQuery, JSON, and XML. ASP.NET Web API does not support higher level protocols such as Reliable Messaging or Transactions.
- Your service does not need to generate client proxies.
- Your service needs full support for REST style services.
In short, choose WCF for reliable and secure service that is accessible over multiple transports. Choose ASP.NET Web API for HTTP based services.