WebService与使用风格RPC/SOA/REST
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?
?
完!
總結
以上是生活随笔為你收集整理的WebService与使用风格RPC/SOA/REST的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: golang语言-1-go普及知识
- 下一篇: 关于Go语言在服务端做Restful接口