sreejith
sreejith

Reputation: 11

When to use WCF REST and WEB API

I am little confused about these two technologies ie WCF REST and asp.net WEB API. Is there any difference between these two? When should use one over the other?

Upvotes: 1

Views: 871

Answers (3)

user585968
user585968

Reputation:

I am little confused about these two technologies ie WCF REST and asp.net WEB API. Is there any difference between these two?

Yes. Both are a means to providing REST-style services however the competing technologies are not created equal.

WCF REST naturally comes from the WCF world which is originally SOAP. WCF REST changes that by providing a rudimentary JSON payload instead of SOAP. However WCF REST is missing certain features and Microsoft has said that newer REST features will only make its way into ASP.NET Web API.

Unlike WCF REST, ASP.NET Web API has been designed from the ground up for REST-style JSON services.

MSDN:

Although WCF provides some support for writing REST-style services, the support for REST in ASP.NET Web API is more complete and all future REST feature improvements will be made in ASP.NET Web API. If you have an existing WCF service and you want to expose additional REST endpoints, use WCF and the WebHttpBinding. - Tell me more

OP:

When should use one over the other?

  • If your intent is to create SOAP services, or you have an existing WCF service, use WCF with a JSON encoding endpoint.

  • If your intent is to create REST services, particularly in a new application, then use ASP.NET Web API.

Upvotes: 2

n.prokhorov
n.prokhorov

Reputation: 930

REST and WCF are the meanings from different worlds :) REST is a specification (in other words the set of conventions) for developing the web-services. REST doesn't depends on some special technology / platform / framework or language. WCF is Microsoft approach for web-services, natively predifined to develope SOAP-services, which are based on RPC-architecture. RPC (remote procedure call) is an approach to develope web-services as a set of methods with parameters, which are doing some work. REST is more HTTP-oriented and the main concept is to operate with some entities (Representational State Transfer) and perform actions to this entities, but not just call some methods. It is possible to build some REST-service using WCF technology, but in my opinion, WCF isn't a good way for this goal.

Upvotes: 0

It depends what you want to do for choose one of them

Basically with the WCF you can create service based applications but with ASP.NET Web Api you can create Restful services based on Http or Https.

Upvotes: 0

Related Questions