WCF or ASP.NET Web API: Which one to choose?

WCF or ASP.NET Web API Which one to choose
Social sharing

Everybody provides API’s to consume these days. Some of the most popular ones are Facebook, Twitter, Google, Github and the list goes on.

API which build services can be consumed by a broad range of clients, including browsers and mobile devices.

In Microsoft platform API can be created by using couple of technologies and they are WCF AND ASP.NET Web API.

Here I am discussing about the major differences between above two technologies.

wcf-vs-web_v_3

Contents

Advantages of Web API  over WCF:

  • Excellent programming model for HTTP.
  • More suitable for access from various browsers, mobile devices etc. enabling wide reach.
  • Enables building APIs that support wide variety of media types including XML, JSON etc.
  • Uses basic protocol and formats such as HTTP, WebSockets, SSL, JQuery, JSON, and XML.
  • HTTP is request/response but additional patterns can be supported through SignalR and WebSockets integration.
  • There is a variety of ways to describe a Web API ranging from auto-generated HTML help page describing code snippets to structured metadata for OData integrated APIs.
  • It is nearly attribute-less and uses convention over configuration to minimize the amount of configuration needed
  • It supports testing well in comparison to WCF infrastructure
  • Web API embraces HTTP’s full goodness such as client-server architecture, web caching, resources, hypermedia, etc.

Advantages of WCF  over Web API:

  • It enables building services that supports multiple transport protocols like HTTP, TCP, UDP, and custom transports
  • Allows switching between multiple transport protocols
  • Enables building services that support multiple encodings (Text, MTOM, and Binary) of the same message type and allows switching between them.
  • Supports building services with WS-* standards like Reliable Messaging, Transactions, Message Security.
  • Supports Request-Reply, One Way, and Duplex message exchange patterns.
  • WCF SOAP services can be described in WSDL allowing automated tools to generate client proxies even for services with complex schemas.

Conclusion:

If you required to use RPC and want to implement enterprise based implementation, then WCF is fine but if you need an API serving all kind of devices Web API is superior.

If you want to move over from HTTP to some other transport, say TCP, NetTCP, MSMQ then WCF will be a better option.

So if we are starting anything from scratch then choose Web API but if you have already have an enterprise WCF app then stick to it.

Recommended Blog: Comparison between ASP.NET MVC or ASP.NET Web Forms

Your recently viewed posts:

Jayadev Das - Post Author

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘About Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

    Contact Us

    We’d love to help & work with you




    When do you want to start ?


    Enter your email address to stay up to date with the latest news.
    Holler Box

    Orange Exit pop up

    Subscribe for the latest
    trends in web and
    mobile app development
    Holler Box

    Exit pop up

    Sad to see you leaving early...

    From "Aha" to "Oh shit" we are sharing everything on our journey.
    Enter your email address to stay up to date with the latest news.
    Holler Box