WCF Service or ASP.NET Web APIs?

By | August 13, 2012

Few days back, while going through a technical forum, I read the following…

“Why do we need WCF now? We can go for new ASP.NET Web APIs framework”

Actually, Windows Communication Foundation is designed to exchange SOAP-based messages using variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ etc. While ASP.NET API is a framework for building non-SOAP based services over HTTP only.

Understanding the difference between the two technologies is the real purpose of this WCF Tutorial. This is a misconception about ASP.NET Web API framework that its going to replaceWCF. It’s just another way of building services that are non-SOAP based e.g. plain XML, JSON string etc. Also it has following advantages as:

  • It allows us to create resource-oriented services using full features of HTTP.
  • Exposing services to variety of clients easily like browsers, mobile devices etc.

WCF is still the best choice for:

  • Messag Queuing scenario using MSMQ.
  • One-way communication or Duplex communication
  • If we intended to use transport other than HTTP e.g. TCP, UDP or Named Pipes.

::::: Free Practical Guide to WCF RESTful Services :::::


Following table further illustrate point by point difference between SOAP-based WCF Service and Web API.

SOAP-based WCF

Web API

 Protocol Multiple Protocol Support. Limited to HTTP only.
 Format SOAP is the default format. SOAP message has a specific format. Web API renders string (Plain XML or JSON string).
 Size Heavy weight as SOAP message have more than just data. Light weight as only required information is passed.
 Principles Follows WS-* specification. Follows REST principles.

Top 10 Interview Questions and Answers Series:

Category: Uncategorized Tags: ,

About IMRAN ABDUL GHANI

Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net, www.topwcftutorials.net, and www.sharepointfordummies.net.

6 thoughts on “WCF Service or ASP.NET Web APIs?

  1. runmygeek

    I dont understand why you said wcf is only for soap based messages ? You can do all action made with webapi with wcf like rest action.

    1. WebdevTutorial

      Hi rummygeek,

      As I started this post with questions I have seen on different forums about WCF.
      Many people think that we don’t need WCF now because ASP.NET Web API is there and it’s a better choice.

      So, my reply was that Web API is undoubtedly a better choice for non-soap based services over HTTP only. But WCF is not limited to it but also do a lot more as I explained above.

      Hopefully, you understand my point now.

      “WCF service is designed to exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, Named Pipes etc)”

  2. Amit Pachahara

    Please add about the advantage of using Restful based services and HTTP based communication.

    Its nice content you put

Comments are closed.