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. |
Other Related Articles:
Top 10 Interview Questions and Answers Series:
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions
- Top 10 ASP.NET AJAX Interview Questions
Good One!
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.
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)”
Very Good.
Please add about the advantage of using Restful based services and HTTP based communication.
Its nice content you put
Amit, please find below URL to understand about Restful and WebAPI services…
http://www.topwcftutorials.net/2012/08/WCF-Or-Web-APIs.html