More about WCF or Web API

Published on Sunday, April 28, 2013

We have had several posts about WCF vs Web API:

1: WCF, WCF Web API and ASP.NET Web API;

2: Abstractions map: WCF Web API vs ASP.NET Web API;

3: WCF or Web API;

4: Host ASP.NET Web API In WPF Application

Today we read another great article “WCF or ASP.NET Web APIs? My two cents on the subject” which was from Ido Flatow’s Blog, here we got more clear answers:

1: Does WCF support Web API ?

Before Web API changed the name from WCF Web API to ASP.NET Web API, we could say WCF supported Web API, but, WCF Web API was not enough to support Web API; We used WebHttpBinding to support Web API;  but now, if you want to use Web API, you maybe have to use the new tech called ASP.NET Web API without WCF, because the new ASP.NET has more features that supports Web API;

2: WCF mainly provides SOAP services, WCF WebHttpBinding provides non-SOAP service over HTTP (called RESTful services), the new Web API provides HTTP Services (Only);

3: WCF is NOT dead because in many cases you have to choose WCF other that ASP.NET Web API:

"If you want to create resource-oriented services over HTTP that can use the full features of HTTP", choose Web API;

"If you use fast transport channels such as TCP, Named Pipes, or maybe even UDP (in WCF 4.5), and you also want to support HTTP when all other transports are unavailable",  you can use WCF with SOAP-based bindings and WebHttp binding.

—– Update:

We found another nice post about REST vs SOAP, the original page is on ASP.NET forum, the poster’s name is bruce sql work dot come, but ASP.NET forum always change, so for avoid the original link broken, let us copy part of content as following:

"REST and SOAP are competing protocols. SOAP uses a xml payload and usually supports wsdl files to define the valid xml (often called a contract).  REST is a simple http protocol that uses the http verbs get,put,post,delete instead of method names. it is payload neutral (ithough xml & json are the most popular).
WCF is a soap hosting technology for .net. It defines contracts for serializing .net object to SOAP messages and back. while its been extended to support REST/JSON functionality its not a pretty picture, as there is no formal contracts with REST

_WebAPI is a new .net framework in MVC4 designed to support REST apis, without the complexty WCF adds. _

WCF/SOAP is best used for typed messages over SOAP. Its ideal for both .net and J2EE because they are simularly typed languages and have tooling for the wsdl.

REST/JSON is bested used when talking to dynamic languages like javascript, objective-c, php, and ruby."