none
WCF vs Web API, Deeper details? RRS feed

  • Question

  • Before I continue, I just want to mention I have heavily researched and searched on this topic, but I need the opinion of people who have worked/and or have practical knowledge with regards to this topic.

    We are currently looking at developing an API so that clients can utilize this. We are definitely set on REST as opposed to SOAP, but I am still a little unclear about what exactly the difference is, if you go down to microscopic detail.

    Having a look at msdn (Choosing which technology to use), the link below:

    http://msdn.microsoft.com/en-us/library/jj823172.aspx

    The differences are clear. However, the first point states for WCF:

    Enables building services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between them.

    For ASP.NET Web Api:

    HTTP only. First-class programming model for HTTP. More suitable for access from various browsers, mobile devices etc enabling wide reach.

    So, both support HTTP, but WCF supports more protocols in addition. What makes ASP.NET Web API more suitable for, I quote: "More suitable for access from various browsers, mobile devices etc enabling wide reach." if both support HTTP?

    We have until now, relied heavily on PC use. What I am getting to, and finally my question is:

    We plan on going mobile, and moving a lot more to multiple devices, browsers etc. But I just would not like to go on a service on the basis of a bit of text saying "Web API" is more suitable? IS it more efficient, less resource intensive etc.? With regards to future proofing? Would we be better of with WEB API and why? Just lastly, we have existing SOAP services, everything we have is built in SOAP.

    Please do not hesitate to go into detail, I am not an experienced dev, just trying to add a contribution to this project.

    Just a last couple of requirements:

    1) We plan on utilizing JSON. 2) We are limited to .NET 3.5/4. 3) Must be REST.

    • Moved by Kristin Xie Wednesday, January 14, 2015 2:16 AM move to appropriate forum
    Tuesday, January 13, 2015 1:10 AM

Answers

  • Its all hype for the different products written by different product teams with incentive to get their baby adopted. Ignore them all and evaluate what you need, not what they need you to want.

    What I do know if that ASP.NET projects require a heap of infrastructure (eg IIS, and associated configuration), whereas WCF can be built as stand-alone services that just run with minimal configuration (typically registering the root URL with http.sys). This is the biggest win for me - recently we had some older ASP.NET projects that we had to integrate with, and what could have been an easy task with some WCF services was a huge PiTA as we had to go through a mass of setup instructions (that were not necessarily up to date, of course) to get something working, not to mention the installation of system services to do this.

    So you need to consider the future maintenance involved. If WebAPI requires a heap of setup, then I'd avoid it.

    There are alternatives, WWS is much more efficient as WCF and supports the same protocols (not that it matters if you're only using HTTP). If you are just building a REST API then any web server, embedded or not, will do. (eg I added Mongoose to one of my services recently, so now it serves http to clients as well, seamlessly and really simple though using C++ not C#).

    Tuesday, January 13, 2015 11:34 AM

All replies

  • The answer does not need much detail.

    WCF is not only for web application, but also for creating Windows Services inside the Microsoft Windows Desktop OS.

    Be aware that WCF and Web Api are the same alike as apples and peers.

    WCF is a package with which you can create Web services, not web components, which can be used in other applications.

    You can create around those services your own data interfaces (Api's like Google calls them).

    Maybe better to write, if you look at net then everybody is using these names with different meanings. If you look at the way it is written in Wikipedia you maybe can recognize the high restraint in which it is written. 

    http://en.wikipedia.org/wiki/Application_programming_interface#Web_APIs


    Success
    Cor


    Tuesday, January 13, 2015 9:16 AM
  • Its all hype for the different products written by different product teams with incentive to get their baby adopted. Ignore them all and evaluate what you need, not what they need you to want.

    What I do know if that ASP.NET projects require a heap of infrastructure (eg IIS, and associated configuration), whereas WCF can be built as stand-alone services that just run with minimal configuration (typically registering the root URL with http.sys). This is the biggest win for me - recently we had some older ASP.NET projects that we had to integrate with, and what could have been an easy task with some WCF services was a huge PiTA as we had to go through a mass of setup instructions (that were not necessarily up to date, of course) to get something working, not to mention the installation of system services to do this.

    So you need to consider the future maintenance involved. If WebAPI requires a heap of setup, then I'd avoid it.

    There are alternatives, WWS is much more efficient as WCF and supports the same protocols (not that it matters if you're only using HTTP). If you are just building a REST API then any web server, embedded or not, will do. (eg I added Mongoose to one of my services recently, so now it serves http to clients as well, seamlessly and really simple though using C++ not C#).

    Tuesday, January 13, 2015 11:34 AM
  • Wow three questions from TechEliteBattleField and all answered in the same style by EngSoonCheah

    Success
    Cor

    Tuesday, January 13, 2015 2:42 PM
  • We are currently looking at developing an API so that clients can utilize this.

    WCF is about SOA with WCF being top-dog, and WEB API is not as  robust as WCF. Nowhere in the ballpark is WEB API as robust when it comes to developing SOA solutions than WCF.

    http://en.wikipedia.org/wiki/Service-oriented_architecture

    http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF

    http://www.dotnet-tricks.com/Tutorial/webapi/VG9K040413-What-is-Web-API-and-why-to-use-it-?.html

    WEB API? Would I use Web API as a development platform to present to external clients as some kind of a SOA solution? The answer would be no, but it can be done - that is create simple services non SOAP based, which would only be used by internal clients in my view.

    The WCF and WEB API forums are in the link below, because you are in the wrong forum asking about either one of the technologies.

    http://forums.asp.net/

    Tuesday, January 13, 2015 3:09 PM
  • We have been using self-hosted WCF services for years. By self-hosted, I mean that they run as a Windows service rather than in IIS. Up until very recently we had not had the need for a REST service, but when that need came up last year, like all our other services, we created a self-hosted WCF service that just happens to be REST. It's a very simple REST service, so I can't say whether or not something more complex is better suited to use ASP.NET Web API, but we have gone the route we have because we are not ASP.NET developers at all and we wanted to continue to stay away from that.

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Tuesday, January 13, 2015 4:25 PM
    Moderator