WebService与使用风格RPC/SOA/REST

一 webservice

Web Services 可使您的应用程序成为 Web 应用程序。Web Services 通过 Web 进行发布、查找和使用。通过使用 Web Services,您的应用程序可以向全世界发布信息,或提供某项功能。

1) 什么是Web Services?
Web Services 是应用程序组件
Web Services 使用开放协议进行通信
Web Services 是独立的(self-contained)并可自我描述
Web Services 可通过使用UDDI来发现
Web Services 可被其他应用程序使用
XML 是 Web Services 的基础

2)它如何工作?
基础的 Web Services 平台是 XML + HTTP。

HTTP 协议是最常用的因特网协议。XML 提供了一种可用于不同的平台和编程语言之间的语言。

Web services 平台的元素:
•SOAP (简易对象访问协议)
•UDDI (通用描述、发现及整合)
•WSDL (Web services 描述语言)

3)工作过程,如图:

二 SOAP

SOAP 是指简单对象访问协议(simple object access protocal)。

SOAP是基于 XML 的简易协议,可使应用程序在 HTTP 之上进行信息交换。或者更简单地说:SOAP 是用于访问网络服务的协议。

1) 什么是 SOAP?
•SOAP 指简易对象访问协议
•SOAP 是一种通信协议
•SOAP 用于应用程序之间的通信
•SOAP 是一种用于发送消息的格式
•SOAP 被设计用来通过因特网进行通信
•SOAP 独立于平台
•SOAP 独立于语言
•SOAP 基于 XML
•SOAP 很简单并可扩展
•SOAP 允许您绕过防火墙
•SOAP 将被作为 W3C 标准来发展

2)Why SOAP?
对于应用程序开发来说,使程序之间进行因特网通信是很重要的。

目前的应用程序通过使用远程过程调用(RPC)在诸如 DCOM 与 CORBA 等对象之间进行通信,但是 HTTP 不是为此设计的。RPC 会产生兼容性以及安全问题;防火墙和代理服务器通常会阻止此类流量。

通过 HTTP 在应用程序间通信是更好的方法,因为 HTTP 得到了所有的因特网浏览器及服务器的支持。SOAP 就是被创造出来完成这个任务的。

SOAP 提供了一种标准的方法,使得运行在不同的操作系统并使用不同的技术和编程语言的应用程序可以互相进行通信。

三 WSDL

WSDL 指网络服务描述语言 (Web Services Description Language)。

WSDL 是一种使用 XML 编写的文档。这种文档可描述某个 Web service。它可规定服务的位置,以及此服务提供的操作(或方法)。

1) 什么是 WSDL?
•WSDL 指网络服务描述语言
•WSDL 使用 XML 编写
•WSDL 是一种 XML 文档
•WSDL 用于描述网络服务
•WSDL 也可用于定位网络服务
•WSDL 还不是 W3C 标准

四 UUDI

UDDI 是一种目录服务,企业可以使用它对 Web services 进行注册和搜索。

UDDI,英文为 "Universal Description, Discovery and Integration",可译为“通用描述、发现与集成服务”。


1)什么是 UDDI?
UDDI 是一个独立于平台的框架,用于通过使用 Internet 来描述服务,发现企业,并对企业服务进行集成。

•UDDI 指的是通用描述、发现与集成服务
•UDDI 是一种用于存储有关 web services 的信息的目录。
•UDDI 是一种由 WSDL 描述的 web services 界面的目录。
•UDDI 经由 SOAP 进行通信
•UDDI 被构建入了微软的 .NET 平台
UDDI 基于什么?
UDDI 使用 W3C 和 IETF* 的因特网标准,比如 XML、HTTP 和 DNS 协议。

UDDI 使用 WSDL 来描述到达 web services 的界面

2)UDDI 的好处
任何规模的行业或企业都能得益于 UDDI。

在 UDDI 之前,还不存在一种 Internet 标准,可以供企业为它们的企业和伙伴提供有关其产品和服务的信息。也不存在一种方法,来集成到彼此的系统和进程中。

UDDI 规范帮助我们解决的问题:

•使得在成百万当前在线的企业中发现正确的企业成为可能
•定义一旦首选的企业被发现后如何启动商业
•扩展新客户并增加对目前客户的访问
•扩展销售并延伸市场范围
•满足用户驱动的需要,为在全球 Internet 经济中快速合作的促进来清除障碍


3) UDDI 如何被使用
假如行业发布了一个用于航班比率检测和预订的 UDDI 标准,航空公司就可以把它们的服务注册到一个 UDDI 目录中。然后旅行社就能够搜索这个 UDDI 目录以找到航空公司预订界面。当此界面被找到后,旅行社就能够立即与此服务进行通信,这样由于它使用了一套定义良好的预订界面。


4)谁在支持 UDDI?
UDDI 是一个跨行业的研究项目,由所有主要的平台和软件提供商驱动,比如:Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, 以及 Sun, 它既是一个市场经营者的团体,也是一个电子商务的领导者。已有数百家公司参与了这个 UDDI 团体。

五 WebService的使用方式RPC/SOA/Rest

1) Remote Procedure Call( RPC ) (based on operation, by calling function or method)

RPC Web services present a distributed function (or method) call interface that is familiar with many developers. Typically, the basic unit of RPC Web services is the WSDL operation.

The first Web services tools were focused on RPC, and as a result this style is widely deployed and supported. However, it is sometimes criticized for not being loosely coupled, because it was often implemented by mapping services directly to language-specific functions or method calls.

Many vendors felt this approach to be a dead end, and pushed for RPC to be disallowed in the WS-I Basic Profile.

Other approaches with nearly the same functionality as RPC are Object Management Group's (OMG) Common Object Request Broker Architecture (CORBA), Microsoft's Distributed Component Object Model (DCOM) or Sun Microsystems's Java/Remote Method Invocation (RMI).

2) Service-oriented architecture(SOA) (based on message, by calling contract or interface)

Web services can also be used to implement an architecture according to Service-oriented architecture (SOA) concepts, where the basic unit of communication is a message, rather than an operation. This is often referred to as "message-oriented" services.

SOA Web services are supported by most major software vendors and industry analysts. Unlike RPC Web services, loose coupling is more likely, because the focus is on the "contract" that WSDL provides, rather than the underlying implementation details.

Middleware Analysts use Enterprise Service Buses which combine message-oriented processing and Web Services to create an Event-driven SOA. One example of an open-source ESB is Mule, another one is Open ESB.

2)Representational State Transfer (REST)。(based on stateful resources)

Representational State Transfer (REST) attempts to describe architectures which use HTTP or similar protocols by constraining the interface to a set of well-known, standard operations (like GET, POST, PUT, DELETE for HTTP). Here, the focus is on interacting with stateful resources, rather than messages or operations.

An architecture based on REST (one that is 'RESTful') can use WSDL to describe SOAP messaging over HTTP, can be implemented as an abstraction purely on top of SOAP (e.g., WS-Transfer), or can be created without using SOAP at all.

WSDL version 2.0 offers support for binding to all the HTTP request methods (not only GET and POST as in version 1.1) so it enables a better implementation of RESTful Web services.[6] However, support for this specification is still poor in software development kits, which often offer tools only for WSDL 1.1.

六 参考

http://en.wikipedia.org/wiki/Web_service

http://www.w3school.com.cn/webservices/index.asp

http://en.wikipedia.org/wiki/Representational_State_Transfer 

完!


作者:iTech
微信公众号: cicdops
出处:http://itech.cnblogs.com/
github:https://github.com/cicdops/cicdops

原文地址:https://www.cnblogs.com/itech/p/1768327.html