WCF or Web Api ? Make your own choice.

By | December 12, 2016

There are lots of article out there to explain you the difference between WCF and Web Api. But while working in practical scenarios which one to choose ? In this article I will cover the difference from the pragmatic point of view which should help you to choose the best among WCF and web api.

WCF vs Web API

               Scenarios for WCF                         Scenarios for Web API
WCF is based on SOAP protocol Web Api is based on REST architecture
Client need to have a proxy to contact the service operations. Learn how to create a client proxy here. There is no need for client to have a proxy. The client can simple make a HTTP call to the URL and access the resources.
 If there are any changes done to the service, client need to know the changes through the WSDL document or changes in the proxy class at client side There is no need for the client to update any documents or base class when changes are done for service
To test the service we need to use the tools like WCFTestClient to check the results There is no need to have any tools to test the output. We can see the output in any web client like IE, chrome etc.
WCF supports various bindings like NetTcp, basicHttp, IPC, wsHttp.  Web Api supports only HTTP protocol which is stateless.
WCF supports SOAP based output files which are basically XML files. It also supports Json format for WebBindings.  WCF supports output in form of Json, Text or it can support custom output formatters.
Supports client proxy initialization like PerCall, Single, or per session based on the requirements Does not provide any such functionality
With WCF we have a very great functionality of exposing the Metadata in which client can know about the operations beforehand. With web api we need to have well documented model so that client can know what it can access.
WCF uses SOAP faults to transport the faults and exceptions across the wire. Web Api uses Status code to show the success or error to the client.
Operations in WCF can be invoked in many ways. We can invoke operations in many ways like Request/Response, One-way operation, call back and async calls. Web API call only support request- response way of invoking the api methods.



I have covered all the possible differences between WCF and Web Api. If you are aware of any other differences please leave a comment.

  • Amit Kundalwal

    We can have WCF also in restful style with WebHTTPBinding which work pretty much as Url based scheme also regarding documention you can integrate swagger which can provide you way to test as well providing documention of API’s,
    biggest advance of Web API is OAuth and Odata