转 Difference between WCF and Web API and WCF REST and Web Service

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

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

Posted By : Shailendra Chauhan, 05 Apr 2013
Updated On : 13 Apr 2013
 Total Views : 126,254   
 

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.

 
相关文章
|
2月前
|
开发框架 监控 .NET
Visual Basic的Web服务和REST API开发指南
【4月更文挑战第27天】本文探讨了使用Visual Basic(VB.NET)构建Web服务和RESTful API的方法。首先介绍了Web服务的基础和REST API的概念,然后阐述了.NET Framework与.NET Core/.NET 5+对VB.NET的支持,以及ASP.NET Core在Web开发中的作用。接着,详细讲解了创建RESTful API的步骤,包括控制器与路由设置、模型绑定与验证,以及返回响应。此外,还讨论了安全措施、测试方法、部署选项和监控策略。最后强调,VB.NET开发者可以通过ASP.NET Core涉足现代Web服务开发,拓宽技术领域。
|
4天前
|
设计模式 缓存 JavaScript
API设计模式:REST、GraphQL、gRPC与tRPC全面解析
API设计模式:REST、GraphQL、gRPC与tRPC全面解析
9 0
|
2月前
|
缓存 前端开发 API
构建可扩展的API:REST vs GraphQL
【5月更文挑战第14天】在API设计中,REST和GraphQL是两种主要的架构风格。REST基于HTTP协议,强调资源的无状态性和客户端-服务器模型,适合简单CRUD操作。而GraphQL提供更灵活的数据查询,允许客户端精确指定需求,减少HTTP请求和数据冗余,适合复杂场景和高性能需求。选择时要考虑项目需求、技术栈、性能和团队经验。
|
25天前
|
JavaScript 前端开发 定位技术
Rest风格WEB服务(Rest Style Web Service)的真相
Rest风格WEB服务(Rest Style Web Service)的真相
34 1
|
2月前
|
XML API 网络架构
Web Service和Web API理解和使用场景
**Web Service**是一种基于网络、使用SOAP协议和XML的数据封装的重服务,适用于跨平台、跨语言的企业系统集成,尤其在安全性和事务处理严格的场景,如银行系统。而**Web API**是轻量级的HTTP接口,常遵循REST原则,使用JSON格式,适合移动应用、开放平台和微服务间的通信,因其简洁高效。选择哪种取决于项目需求,Web Service适合复杂交互,Web API则流行于现代Web应用。
|
2月前
|
Prometheus 监控 Cloud Native
第七十一章 使用 REST API 监控 IRIS - 活动量指标
第七十一章 使用 REST API 监控 IRIS - 活动量指标
24 0
|
2月前
|
监控 API 网络架构
第七十章 使用 REST API 监控 IRIS - 互操作性指标
第七十章 使用 REST API 监控 IRIS - 互操作性指标
24 0
|
2月前
|
SQL 监控 API
第六十九章 使用 REST API 监控 IRIS
第六十九章 使用 REST API 监控 IRIS
24 0
|
2月前
|
分布式计算 DataWorks 关系型数据库
DataWorks操作报错合集之在DataWorks同步数据时,遇到乱码问题,该怎么解决(rest api数据源)
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
39 0
|
2月前
|
JSON 安全 API
【专栏】四种REST API身份验证方法:基本认证、OAuth、JSON Web Token(JWT)和API密钥
【4月更文挑战第28天】本文探讨了四种REST API身份验证方法:基本认证、OAuth、JSON Web Token(JWT)和API密钥。基本认证简单但不安全;OAuth适用于授权第三方应用;JWT提供安全的身份验证信息传递;API密钥适合内部使用。选择方法时需平衡安全性、用户体验和开发复杂性。