Saturday, September 23, 2017

WCF vs WebAPI

Some fact about WCF :

If you need to communicate over pure TCP socket or any other protocol then HTTP use WCF. WCF can communicate is wide range of protocol.
Creating services that are transport/protocol independent. Single service with multiple endpoints.
Like one WCF service can have multiple endpoints based on clients. For example- One  web application request protocol -> http and response -> xml, another client could be TCP and Binary response.

If you have limitation and stuck with .Net framework 3.5 then create WCF restful service otherwise use WebAPI Resuful service. Lot of configuration is required to turn WCF service to turn in to Restful service.

Now WebAPI:
WebAPI is Restful service which only rely on HTTP protocol.

REST Constraints:
Client Server: In REST architecture there is always a client and a server where the communication is always initiated by the client. The client and server are decoupled by a uniform interface there by making both the client and server to develop independently. Every resource in the server is accessed by a unique address (URI).

Stateless : we should not storing anything related to client on server.

Cacheable: some data provided by server does not change that often, so let client know how long data is good and does not require change and avoid requests to server.

Uniform Interface: An important concept of REST is the uniform interface. The uniform interface contains a set of methods that can be understood by both the client and the server. In the HTTP uniform interface the important methods are GET, POST, PUT, DELETE, HEAD and OPTIONS. It is important to choose the right method for the right operation. For ex. if the client is going to get the resource from the server then they should use GET method.
Share:

0 comments:

Post a Comment