webservicewebapi(webservicewebapi区别)

http://www.itjxue.com  2023-02-20 00:14  来源:未知  点击次数: 

WebService、WCF和WebApi的区别和特点

Web Service :Web Service服务通常被定义为一组模块化的API,它们可以通过网络进行调用,来执行远程系统的请求服务

1.)它是基于SOAP协议的,数据格式是XML

2.)只支持HTTP协议

3.)它不是开源的,但可以被任何一个了解XML的人使用

4.)它只能部署到IIS上

WCF :是由微软开发的一系列支持数据通信的应用程序框架,整合了原有的windows通讯的 .net Remoting,WebService,Socket的机制,并融合有HTTP和FTP的相关技术

1.)它也是基于SOAP的,数据格式是XML

2.)它是Web Service的进化版,可以支持各种各样的协议,像TCP,HTTP,HTTPS等

3.)WCF配置较为繁琐

4.)它不是开源的,但可以被任意一个了解XML的人使用

5.)它可以部署到应用程序中或IIS及Windows服务中

Web Api :与WCF REST Service不同在于,Web API利用Http协议的各个方面来表达服务

1.)在.net平台上Web Api是一个开源的、理想的、构建REST-ful服务的技术

2.)它可以使用HTTP的全部特点,比如URIs、request/response头,缓存,版本控制,多种内容格式

3.)它也支持MVC的特征,像路由、控制器、action、filter、模型绑定、控制反转(IOC)或依赖注入(DI),单元测试

4.)它可以部署在应用程序和IIS上

5.)这是一个轻量级的框架,并且对限制带宽的设备,比如智能手机等支持的很好

6.)Response可以被Web API的MediaTypeFormatter转换成Json、XML 等格式

WebAPI与传统的WebService有哪些不同

WebAPI 采用 REST 架构,相对于 WebService 来说,极大的减轻了开发人员的负担,毕竟不是每个开发人员都了解 Web Service 协议。

因为你用不到 Web Service 协议的特性,因此你也不必创建这类应用来迎合别人,但是又要让别人和你交互,那么最低限度的按照 REST 架构来设计接口,这将极大的减轻你的工作负担。

WebService和Webapi的区别

WebApi是基于纯粹的http协议,webservice是基于soap协议(比简单的http协议更高级)。

WebApi有取代webservice的趋势,至少,非必要,一般咱也不会优先选择webservice。

WCF,WebAPI,WCFREST和WebService的区别

Web Service

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

It support only HTTP protocol.

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

It can be hosted only on IIS.

WCF

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

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

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

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

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

WCF Rest

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

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

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

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

It support XML, JSON and ATOM data format.

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.

To whom choose between WCF or WEB API

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

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.

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

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

从WebService到WebAPI

??1996年,Gartner前瞻性地提出了面向服务架构的思想(SOA)。

??Service Oriented Ambiguity 中文一般理解为:面向服务架构,简称SOA,这个概念算得上微服务的鼻祖了。

??SOA 的提出是在企业计算领域,就是要将紧耦合的系统,划分为面向业务的、粗粒度、松耦合、无状态的服务。服务发布出来供其他服务调用,一组互相依赖的服务就构成了SOA架构下的系统。

?? SOA本质上是服务的集合。

??微软技术栈下:

??总体来说,两者都是服务,只是表现形式存在一些差异:

1、518fans粉丝网的

2、无为无味无心的

3、cysong168的博客

4、百度知道

WebService与WebApi的区别

1 基于SOAP协议的,数据格式为XML

2 只支持HTTP协议

3 不是开源的,但可以被任意一个了解XML的人使用

4 只能部署在IIS上

SOAP :简单对象访问协议Simple Object Access Protocol,传输层 ,,XML传输消息

WSDL :Web Server Description Language :Web Server描述语言(元数据),给客户端生成代理类的一个描述信息

UDDI :提供了一组基于标准的规范用于描述和发现服务,统一描述,发现和集成(UDDI-Universal Descript,Discovery,Integration),提供注册和查找服务

客户端在UDDI注册表(Registry)查找服务,取得服务的WSDL描述,通过SOAP调用服务。

1 是简单的 构建HTTP服务的新框架

2 在.net平台上WebApi是一个开源的,理想的,构建REST-FUL服务的技术

3 不想WCF REST Server 它可以使用HTTP的全部特点(URI,request/response头,缓存,版本控制,多种内容格式)

4 支持MVC的特征。像路由、控制器、action、filter、模型绑定、控制反转(IOC)或依赖注入(DI),单元测试。

4 可以部署在IIS和应用程序上

6 轻量级框架,并且对限制带宽的设备,比如智能手机等支持的很好

7、Response可以被Web API的MediaTypeFormatter转换成Json、XML 或者任何你想转换的格式。

8、Web API非常适合构建移动客户端服务

1、 需要Web Service但是不需要SOAP

2、 需要在已有的WCF服务基础上建立non-soap-based http服务

3、 只想发布一些简单的Http服务,不想使用相对复杂的WCF配置

4、 发布的服务可能会被带宽受限的设备访问

5、 希望使用开源框架,关键时候可以自己调试或者自定义一下框架

6、如果服务需要在http协议上,并且希望利用http协议的各种功能

7、如果服务需要被各种客户端(特别是移动客户端)调用

webapi多用于基于http请求的服务应用,比如说移动服务端或者需要提供第三方API 服务的场景下

webservice也可以应用于webapi所在的场景,一般是做为内部服务的使用,好比如果一个系统用wcf/webservice作为内部子系统间的服务通信,而webapi用于外部服务的请求。

(责任编辑:IT教学网)

更多