What is the difference between Asp.Net Web API and WCF Service?

Since last few months this Asp.Net Web API seems to be an highlighted product from Microsoft. Is it an alternative to WS* Service. How is it different than WCF Service? And where can we see it as a best fit in web application development?


ASP.NET Web API is a framework for building web services that are exposed over HTTP. It is very well suited to (but not limited to) building RESTful web services.

Such web services are an alternative to building a SOAP RPC / WS* web services in that they are simpler, more light weight, and there's less coupling between client and server.

A traditional "WCF Service" supports SOAP RPC as opposed to REST, and these services tend to be complex and to have a tight coupling between client and server. Wide interoperability can become difficult to achieve. However, a traditional WCF Service can communicate over a wide variety of protocols - TCP being a particularly useful one for internal services (services in the same DMZ).

(While WCF is mostly associated with SOAP RPC-style services, there are at least three attempts in WCF to support the building of RESTful web services. These attempts have all been superseded by the ASP.NET Web API.)

ASP.NET Web API is a best fit for producing public facing RESTful web services - aka Hypermedia APIs - over HTTP. To do this, having a good understanding of the REST architectural style is important before you start using the ASP.NET Web API. See such books as "REST in Practice", "The RESTful Web Services Cookbook" and "Building Hypermedia APIs with HTML5 and Node".


Difference between ASP.net Web API and WCF API

Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.

链接地址: http://www.djcxy.com/p/54326.html

上一篇: WCF数据服务(OData)与ASP.NET Web API

下一篇: Asp.Net Web API和WCF Service有什么区别?