Can any one share the actual difference between WCF Service and ASP.NET Web Api? In which scenario we have to use WCF Service and ASP.NET Web Api.
Use WCF to create reliable, secure web services that are accessible over a variety of transports. Use ASP.NET Web API to create HTTP-based services that are accessible from a wide variety of clients. Use ASP.NET Web API if you are creating and designing new REST-style services.
No, it's not true that ASP.NET Web API has replaced WCF. WCF was generally developed to develop SOAP-based services. ASP.NET Web API is a new way to develop non-SOAP-based services such as XML, JSON, etc.
WEB API can use any text format including XML and is faster than WCF. WEB API can be used to create full-blown REST Services. WEB API doesn't require any data contracts and doesn't require configurations to the level of WCF.
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. It is not open source software. It is shipped with.Net framework.It is also available as an independent download.
WCF Web API is the next generation of Microsoft's service framework.
WCF Services were originally designed with a channel architecture allowing customization of the protocols and transports used to communicate between systems. While this gives the architect/developer great flexibility in building inter-operable applications, it comes at the cost of complexity. Configuring WCF has never been simple (IMO).
The most prevalent use case (IMO), is using WCF services to provide support to web applications via ajax requests from the browser for additional data. Also, since the time that WCF was originally introduced, it has become common for applications to provide an API using http.
Because the of this, the new WCF Web API is an attempt to simplify the service infrastructure and assume the http transport protocol.
If you are building a new web application, I would use the new Web API. I would only look at using WCF Services if I needed to communicate with another system using something other http.
WCF Channel Architecture
http://msdn.microsoft.com/en-us/library/ms729840.aspx
WCF Web API
http://www.asp.net/web-api
From http://mattmilner.com/Milner/Blog/post/2012/02/28/WebAPI-or-WCF.aspx, a great post on this issue: "WCF remains the framework for building services where you care about transport flexibility. Web API is the framework for building services where you care about HTTP."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With