Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 452
Saurabh Avatar asked Feb 27 '12 08:02

Saurabh


People also ask

What is the difference between ASP Net Web API and WCF?

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.

What is the difference between WCF and web services?

Web services support only one protocol- HTTP and HTTPS during communication, but WCF supports more protocols like- HTTP, TCP, and MSMQ that can be extended for a comprehensive solution, reliable session, and transactions. It signifies WCF is more adaptable to work together for a variety of software.

Does ASP Net Web API replace the WCF?

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.

Why We Use Web API instead of WCF?

WEB API is a better choice for simpler, light weight services. 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.


1 Answers

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".

like image 108
Bellarmine Head Avatar answered Sep 28 '22 13:09

Bellarmine Head