Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF vs ASP .Net Web API

What are the pros and cons of using each technology?

WCF Web Api is now merged into Asp.net Asp.net web api now supports self hosting.

I still imagine if I want to expose multiple protocol schemas for the same operation I would still lean towards WCF or can Mvc end point do this too?

Also does the new Asp.Net web api expose Wsdl? If not how would the client figure out what operation is available to them?

Arguably the best feature of Mvc is the modelbinder. How robust is the WCF equivalent?

So can someone tell me what advantage does the Asp.net web api bring to the table? WCF seems overwhelmingly the more powerful/scalable choice, imo. About the only thing the Mvc Web Api has over the WCF model is probably ease of development, but that means squat if it ends up being a serious design limitation down the road.

like image 332
Alwyn Avatar asked Mar 19 '12 22:03

Alwyn


People also ask

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

KEY DIFFERENCEWCF is used for developing SOAP-based services whereas Web API is used for both SOAP-based and RESTful services. WCF does not offer any support for MVC features whereas Web API supports MVC features. WCF supports HTTP, UDP, and custom transport protocol whereas Web API supports only HTTP protocol.

Which is better WCF or Web API?

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.

Does ASP Net Web API replace the WCF?

The programming model of ASP.NET Web API resembles ASP.NET MVC in being simple, instead of requiring you to define interfaces, create implementation classes, and decorate them with several attributes. However, the ASP.NET Web API is not supposed to replace WCF anymore.

Is asp net a WCF?

The default configuration for WCF is side-by-side with ASP.NET. The ASP.NET HTTP runtime handles ASP.NET requests but does not participate in the processing of requests destined for WCF services, even though these services are hosted in the same AppDomain as is the ASP.NET content.


2 Answers

First, I suggest you read my post on the subject: http://blogs.microsoft.co.il/blogs/idof/archive/2012/03/05/wcf-or-asp-net-web-apis-my-two-cents-on-the-subject.aspx

Regarding your WSDL question - since the WebApi does not use SOAP, it does not require a WSDL, and does not export one. You can use Hypermedia to return resources with a list of possible activity URLs (think of it as a self-describing resource)

like image 195
IdoFlatow Avatar answered Sep 30 '22 16:09

IdoFlatow


The choice depends on what we want to do.

  1. ASP.NET Web API is a framework for building non-SOAP based services over HTTP only - so there aren't more transport protocols available using this framework.
  2. WCF / Windows Communication Foundation is a framework for exchanging SOAP-based messages - here we use a lot of transport protocols: HTTP, TCP, Named pipes, MSMQ, etc...

I am not sure about which one has better performance regarding the amount of data, maybe WCF since we can use low protocols. Any comments are appreciated.

like image 35
Junior Mayhé Avatar answered Sep 30 '22 16:09

Junior Mayhé