WCF 、Web API 、 WCF REST 和 Web Service 的区别

简介:   The .Net framework has a number of technologies that allow you to create HTTP services such as Web Service, WCF and now Web API.

  The .Net framework has a number of technologies that allow you to create HTTP services such as Web Service, WCF and now Web API. There are a lot of articles over the internet which may describe to whom you should use. Now a days, you have a lot of choices to build HTTP services on .NET framework. In this article, I would like to share my opinion with you over Web Service, WCF and now Web API. For more information about Web API refers What is Web API and why to use it ?.

Web Service

  1. It is based on SOAP and return data in XML form.

  2. It support only HTTP protocol.

  3. It is not open source but can be consumed by any client that understands xml.

  4. It can be hosted only on IIS.

WCF

  1. It is also based on SOAP and return data in XML form.

  2. It is the evolution of the web service(ASMX) and support various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.

  3. The main issue with WCF is, its tedious and extensive configuration.

  4. It is not open source but can be consumed by any client that understands xml.

  5. It can be hosted with in the applicaion or on IIS or using window service.

WCF Rest

  1. To use WCF as WCF Rest service you have to enable webHttpBindings.

  2. It support HTTP GET and POST verbs by [WebGet] and [WebInvoke] attributes respectively.

  3. To enable other HTTP verbs you have to do some configuration in IIS to accept request of that particular verb on .svc files

  4. Passing data through parameters using a WebGet needs configuration. The UriTemplate must be specified

  5. It support XML, JSON and ATOM data format.

Web API

  1. This is the new framework for building HTTP services with easy and simple way.

  2. Web API is open source an ideal platform for building REST-ful services over the .NET Framework.

  3. Unlike WCF Rest service, it use the full featues of HTTP (like URIs, request/response headers, caching, versioning, various content formats)

  4. 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.

  5. It can be hosted with in the application or on IIS.

  6. It is light weight architecture and good for devices which have limited bandwidth like smart phones.

  7. Responses are formatted by Web API’s MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.

To whom choose between WCF or WEB API

  1. Choose WCF when you want to create a service that should support special scenarios such as one way messaging, message queues, duplex communication etc.

  2. Choose WCF when you want to create a service that can use fast transport channels when available, such as TCP, Named Pipes, or maybe even UDP (in WCF 4.5), and you also want to support HTTP when all other transport channels are unavailable.

  3. Choose Web API when you want to create a resource-oriented services over HTTP that can use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats).

  4. Choose Web API when you want to expose your service to a broad range of clients including browsers, mobiles, iphone and tablets.

引用网址

http://www.dotnet-tricks.com/Tutorial/webapi/JI2X050413-Difference-between-WCF-and-Web-API-and-WCF-REST-and-Web-Service.html

 

相关文章
|
11月前
|
XML JSON API
识别这些API接口定义(http,https,api,RPC,webservice,Restful api ,OpenAPI)
本内容介绍了API相关的术语分类,包括传输协议(HTTP/HTTPS)、接口风格(RESTful、WebService、RPC)及开放程度(API、OpenAPI),帮助理解各类API的特点与应用场景。
|
编译器 API 定位技术
API和SDK的区别
API 和 SDK 的区别在于:API 是一组定义了软件组件之间交互规范的接口,用于实现不同软件组件之间的通信;而 SDK 是一个全面的工具集合,包含 API、编译器、调试器、文档等,用于特定平台的应用程序开发。SDK 范围更广,内容更丰富,更具体和具象化,适合复杂的开发需求;API 则更加抽象,侧重于功能的定义和调用方式。
|
11月前
|
JSON 数据挖掘 API
淘宝详情API接口与高级详情API接口用json返回数据区别
淘宝“商品详情API”与“高级商品API”主要区别在于数据深度、字段丰富度及适用场景。前者适用于轻量级导购展示,后者支持详情页展示与深度分析,需根据业务需求选择使用。
|
11月前
|
搜索推荐 数据挖掘 API
【干货满满】阿里妈妈API接口和淘宝联盟的接口有哪些区别
阿里妈妈API覆盖全链路营销,包含广告投放、数据分析及淘宝客推广,适用于品牌商家与营销工具;淘宝联盟API则专注淘宝客业务,提供商品查询、链接生成与佣金结算等功能,适合推广者使用。两者在功能、权限及应用场景上各有侧重。
|
运维 数据挖掘 API
官方api和第三方api有什么区别
官方API与第三方API是电商商家常用的两种接口类型。官方API由电商平台提供,功能全面、集成度高、安全性强且稳定性好,适合处理核心业务;而第三方API由外部服务商提供,专注特定功能如支付、物流等,灵活性和扩展性更强,但安全性和稳定性参差不齐。商家应根据自身需求、预算及技术能力选择合适的API,确保数据安全与合规性,同时优化运营流程、提升用户体验并拓展业务功能,在竞争中占据优势。
|
SQL 安全 网络安全
Web应用防火墙(WAF)与数据库应用防火墙有什么区别?
Web应用防火墙(WAF)专注于Web应用系统和网站的应用层防护,可有效应对OWASP Top 10等常见攻击,防止SQL注入、CC攻击等。而数据库应用防火墙则位于应用服务器与数据库之间,提供数据库访问控制、攻击阻断、虚拟补丁等高级防护功能,直接保护数据库免受攻击。两者分别针对Web层和数据库层提供不同的安全保护。
589 4
|
编译器 API 定位技术
API和SDK的区别
API(应用程序编程接口)和SDK(软件开发工具包)的主要区别在于范围、内容、抽象程度及使用方式。API定义了软件组件间的交互规则,范围较窄,更抽象;而SDK提供了一整套开发工具,包括API、编译器、调试器等,范围广泛,具体且实用,有助于提高开发效率。
2827 0
|
网络协议 API 网络安全
Web实时通信的学习之旅:轮询、WebSocket、SSE的区别以及优缺点
Web实时通信的学习之旅:轮询、WebSocket、SSE的区别以及优缺点
3414 0
|
存储 前端开发 API
前端开发中,Web Storage的存储数据的方法localstorage和sessionStorage的使用及区别
前端开发中,Web Storage的存储数据的方法localstorage和sessionStorage的使用及区别
671 0