Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service or Web API [closed]

Tags:

I'm going to be working on a project that involves a number of elements:

  • ASP.NET MVC website
  • C# console application
  • iPhone App

To get all these separate applications talking to the database, my immediate thought was to use a WCF Service.

However, I now need to add an API to the site to allow third parties to select, insert and update records from their own applications.

In my mind, I would just create a separate RESTful service endpoint on my WCF Service which would be locked down using authentication and would only give access to certain methods.

However, I've been reading today about the Web API feature in MVC 4 which is meant to be the latest thing for RESTful APIs?

Should I be going along the line of using the Web API? or because my other applications need a web service, should I stick with a WCF Service?

like image 408
Dan Ellis Avatar asked Feb 29 '12 16:02

Dan Ellis


People also ask

What is difference between WCF service and Web API?

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.

Does Web API replace 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 WCF discontinued?

As long as the Windows operating system continues to include . NET Framework, WCF will continue to function.

Which is best Web API or WCF?

Web API is considered the best choice over WCF because of the following reasons: Web API uses all features of HTTP such as URIs, request/response headers, caching, versioning, various content formats, etc.


2 Answers

If you intend to do RESTful development then you will definitely want to use the ASP.Net Web Api (which was originally called WCF Web Api and created with the goal of "Making REST a first class citizen in .NET".

Another thing to consider is that the WCF REST Starter kit is no longer supported.

Note that using Web Api doesn't mean you have to use ASP.Net MVC or IIS even as it can be self hosted.

For handling operations which are non-CRUD in nature I'd recommend Googling "REST non-CRUD". I found this blog post RESTful URLs for non-CRUD operations (and particularly the comments interesting). If you decide you NEED to have RPC calls then those may have to be done with WCF. That said since WCF REST is being killed off I'm not sure what the best solution is going to be. Having both is probably the best answer but at the same time it's not necessarily a good answer.

Another alternative would be a WCF OData Service but I'm not sure if that gets any support from an iPhone.

One last point to make (that can be deleted in the future as this is time sensitive)

Microsoft has provided a Go Live license with the beta which means that it is supported by Microsoft and you shouldn't have any problems upgrading to the file RTM.

like image 105
Shane Courtrille Avatar answered Sep 22 '22 04:09

Shane Courtrille


Service Stack also looks like an option.

Demos, overview, examples is available here.

like image 40
Dima Pasko Avatar answered Sep 24 '22 04:09

Dima Pasko