简体   繁体   中英

Rest WCF vs Web api

I read some articles and i search many about differences between Rest WCF vs Web api but I just find difference between WCF vs Web api , I find some difference:

WCF Rest=> a)It support HTTP GET and POST verbs by [WebGet] and [WebInvoke] attributes respectively. b)To enable other HTTP verbs you have to do some configuration in IIS to accept request of that particular verb on .svc files. c)Passing data through parameters using a WebGet needs configuration. The UriTemplate must be specified. d)It support XML, JSON and ATOM data format.

and

WebApi=> a)Unlike WCF Rest service, it use the full featues of HTTP (like URIs, request/response headers, caching, versioning, various content formats). b)Responses are formatted by Web API's MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.

I want know other differences between them, and when is it better to use WebApi and when Rest Wcf ?

I would say, if you start a new project and you need to expose a REST web interface in .NET, Web API is the way to go because AFAIK, WCF is deprecated. I would only consider to use WCF Rest if you have to expose both, SOAP and REST web interfaces.

WCF is not the good choice for REST because it was not made for it, when they implemented it they did lots of bad hacks. you can see how they try to convert xml to josn here

WCF is NOT deprecated, so powerful, and no framework can be comparable to it yet. but it is not for REST.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM