WCF、Web API、WCF REST、Web Service之区别
http://www.dotnet-tricks.com/Tutorial/webapi/JI2X050413-Difference-between-WCF-and-Web-API-and-WCF-REST-and-Web-Service.html
.NET framework 有很多的技术来创建HTTP service,比如:Web Service, WCF 和Web API。下面讲述一下它们的区别:
Web Service
- 基于SOAP,并且返回XML数据。
- 只支持HTTP协议。
- 非开源,但是xml能够被所有的客户端理解并使用。
- 只能驻留在IIS中。
WCF
- 同样基于SOAP,并且返回XML数据。
- 是Web Service的演化版(ASMX)并且支持各种协议比如TCP, HTTP, HTTPS, Named Pipes, MSMQ。
- WCF主要的问题是繁琐的、可扩展的配置。
- 非开源,但是xml能够被所有的客户端理解并使用。
- 能够在IIS中或者其它的window service(window 服务)中驻留。
WCF REST
- 将WCF作为WCF Rest Service,你必须支持webHttpBinding。
- 它支持 HTTP GET和POST。
- 如果要支持其它的HTTP verbs,你必须设置IIS使其能接受其它的verb。
- Passing data through parameters using a WebGet need configuration. The UriTemplate must be specified.
- 支持XML、JSON和ATOM数据格式。
Web API
- This is the new framework for building HTTP services with easy and simple way.
- Web API is open source an ideal platform for building REST-ful services over the .NET Framework.
- Unlike WCF Rest service, it use the full featues of HTTP (like URIs, request/response headers, caching, versioning, various content formats)
- It also supports the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection, unit testing that makes it more simple and robust.
- It can be hosted with in the application or on IIS.
- It is light weight architecture and good for devices which have limited bandwidth like smart phones.
- Responses are formatted by Web API’s MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter