Web Services 原理與應用 以旅遊服務為例

Download Report

Transcript Web Services 原理與應用 以旅遊服務為例

Intelligent Healthcare System and Software Engineering Lab.
服務導向:
SOA & Web Services
潘健一
慈濟大學。醫學資訊系
慈濟技術學院資工系軟體工程產學研習會
1
Intelligent Healthcare System and Software Engineering Lab.
大綱









前言
服務導向架構-SOA
Web services介紹
軟體即服務(software as a service)的概念
Web services的特徵
Web services的技術架構
服務的介面與實作
服務的品質(Quality of Service, QoS)
結論
2
Intelligent Healthcare System and Software Engineering Lab.
前言
 人類社會的發展:農業→工業→逐步邁向以服
務為主的第三產業經濟時代
 服務在主要的OECD國家佔其GDP的比率都已
竄升到70%以上

臺灣已逐漸從製造業為主的產業型態轉型為製
造服務業,同時服務業的產值佔國內生產毛額
(GDP)的比重也達到了73.56%
 服務的形式也從面對面推展到透過網路服務形
式
3
Intelligent Healthcare System and Software Engineering Lab.
服務
服務
服務
服務
服務
服務
服務
4
Intelligent Healthcare System and Software Engineering Lab.
 將軟體與應用程式以網路服務形式進行是未來
資訊服務的趨勢

以各類資訊服務性質來看,軟體產品和應用約
佔資訊服務業之市場比重為 40% ,而網路服務
約佔 32%
5
Intelligent Healthcare System and Software Engineering Lab.
1. 服務導向架構SOA
 服務導向架構 (SOA, Service Oriented
Architecture) 是一種新興的系統架構模型,其
主要概念是針對企業需求組合而成的一組軟體
元件。
 組合的元素通常包括:軟體元件、服務及流程
三個部份
 當企業面對外部要求時



流程定義外部要求的處理步驟;
服務包括特定步驟的所有程式元件,
而元件則負責執行工作的程式。
6
Intelligent Healthcare System and Software Engineering Lab.

例如,當企業面對顧客訂機票要求時,



流程訂定訂機票的處理步驟
服務則包括信用查詢、機位查詢及接單作業等等
元件則是指真正完成信用查詢、機位查詢等工作的
程式
7
Intelligent Healthcare System and Software Engineering Lab.



SOA 的系統組成與企業的經營管理基本單元十
分接近
如此高階的應用系統發展模式可使得發展者更
專注於企業需求的滿足 (coarse grain),而不僅
僅是資訊技術的應用 (fine grain)。
透過 SOA 讓異質系統整合變得容易,程式可再
用度(reusability)也提高。

不必自行開發或擁有所有程式元件,發展者可以視
需要組合網路上最好的服務。不受限於特定廠商的
產品功能或是平台,達到真正的開放性
(Openness)。
8
Intelligent Healthcare System and Software Engineering Lab.
 從分散式元件架構到 SOA


SOA 如同物件導向、軟體元件等軟體技術一般,
運用小的零組件組合成應用系統
但 SOA 強調的是如何將彼此關係鬆散的應用系
統功能元件在網路上發行、組合及使用
 可以整合已存在且非網路應用的軟體(legacy
software system) ,延長軟體的生命週期
9
Intelligent Healthcare System and Software Engineering Lab.
 SOA 具有下列技術特性:




分散式架構 (Distributed)
關係鬆散的界面 (Loosely coupled)
依據開放的標準 (Open standard)
以流程角度出發 (Process centric)
10
Intelligent Healthcare System and Software Engineering Lab.
2. Web services介紹
 W3C的定義

A Web service is a software system identified
by a URL whose public interfaces and
bindings are defined and described using XML.
 Web service 是採用service-oriented
architecture, which is simply a collection of
services that communicate with each other
through well-defined and well-known interface.
11
Intelligent Healthcare System and Software Engineering Lab.
 問題
1:人家怎麼找到你的服務?
2:你製作好的的服務怎麼讓人家知道?
3:某一個Web Service代表的意義何功能是什麼?
4:如何管理Web Services?
12
Intelligent Healthcare System and Software Engineering Lab.
Service Brokers (Registry)
Services
descriptions
Find
Publish
(WSDL, UDDI)
(WSDL, UDDI)
SOAP
Services
Services
descriptions
Bind
(WSDL, UDDI)
Service Requesters
Service Providers
13
Intelligent Healthcare System and Software Engineering Lab.
3. Software-as-service的概念
 Web service與web page是完全不一樣的概念


Web pages的使用者目標是一般人
Web service的使用者則不一定指人,也可以其
他的軟體
 Software as a service的概念源自於application
service providers (ASPs)


『租』軟體
缺乏一個真正能跨平台工作的標準
14
Intelligent Healthcare System and Software Engineering Lab.
 Web service的形式分類
request
request
OP
response
OP
Port
Web
service
response
request
Port
合作
Port
OP
Web
service
Type I web service
OP
response
Type II web service
15
Intelligent Healthcare System and Software Engineering Lab.
4. Web services的特徵
 跨程式語言平台
 底層的運作(資料的傳輸及服務的呼叫)皆以XML
作為local和remote溝通及互動的表達語言
 SOAP以XML為基礎並架構在HTTP之上
 SOAP是以文字為基礎的通訊協定
 Loosely coupling
 Web Services Description Language
 動態地呼叫與使用Web Service所提供的服務
 動態服務的取得
 UDDI
16
Intelligent Healthcare System and Software Engineering Lab.
 提供同步與非同步的運算模式



Synchronous service:RPC (remote
procedure call)
Asynchronous service:document-style or
message-driven
IBM MQ Server, MS MSMQ
 透通防火牆的保護

HTTP
17
Intelligent Healthcare System and Software Engineering Lab.
5. Web services的技術架構
 UDDI (Universal Description, Discover,
Integration Protocol)

負責服務註冊與服務查詢
 WSDL (Web Services Description Language)

提供服務描述與介面描述
 SOAP (Simple Object Access Protocol)
 訂定服務包裝與傳送的標準
 XML (eXtensible Markup Language)
 跨平台的標準基礎
18
Intelligent Healthcare System and Software Engineering Lab.
UDDI
 Universal Description, Discover, Integration
Protocol
 UDDI是標準的Web Service資訊存取的方式,
內含

服務內容



服務名稱,敘述
細節及分類
連結資訊



實作敘述
服務存取URL,如WSDL的URL
該服務的參數
19
Intelligent Healthcare System and Software Engineering Lab.
WSDL
 Web Services Description Language
 使用XML程式撰寫,用來描述服務定義與服務
溝通的方式
20
Intelligent Healthcare System and Software Engineering Lab.
網
路
服
務
描
述
範
圍
協
議
Business Level Agreement
關
聯
Composition
Service Level Agreement
Orchestration
Presentation
服
務
細
節
Policy
Implementation Description
Interface Description
網路服務描述完整範圍
WSDL只佔其中兩部份
Service【實作服務】
Port【服務端點】
Types【資料類型集】
Message【訊息】
PortType【介面定義】
Binding【服務鏈結】
21
Intelligent Healthcare System and Software Engineering Lab.
 Name Space

XML為了防止檔案內的標記衝突的問題
 Documentation


嵌入的說明文字,便於人們閱讀了解
是一個選擇性的
 Import


提供引入之功能
能將WSDL定義部份引入文件中,使interface
description 能共用
22
Intelligent Healthcare System and Software Engineering Lab.
SOAP
 Simple Object Access Protocol
 Lightweight XML-based messaging format
 適合應用的範圍



Any operating system
Any programming language
Any platform
 Builds on

W3C XML standards
23
Intelligent Healthcare System and Software Engineering Lab.
Protocol Headers
整個 SOAP Message
標準的 Protocol (HTTP, SMTP, etc.)
與 SOAP Headers
SOAP Envelope
<Envelope> encloses payload
SOAP Message
SOAP Header
<Header> encloses headers
Headers
SOAP Body
Message Name & Data
<Body> 包含 SOAP
訊息名稱與資料
XML 編碼的 SOAP
訊息名稱與資料
24
Intelligent Healthcare System and Software Engineering Lab.

描述 web site 所提供的 Web Services

Web Services 所定義的格式與訊息順序

Web Service Provider and Consumers
之間利用 XML 送、收訊息

所有的這些性能都建立再使用開放的
Internet protocols
SOAP
Discovery
SOAP
Contract Language
SOAP
XML, XSD
HTTP, SMTP
25
Intelligent Healthcare System and Software Engineering Lab.
XML
 eXtensible Markup Language


A Syntax for Documents
A Meta-Markup Language
 A Structural and Semantic Language, not a
Formatting Language
 Not just for Web pages XML Schema
26
Intelligent Healthcare System and Software Engineering Lab.
 XML Parsing及文件轉換的功能
 JAXP (Java API for XML Processing)
 XML Parsing模型有兩程
 DOM (Document Object Model)



利用標籤間具有階層性的關係,在記憶體中以樹狀
結構的方式重現XML文件
利用traversal的演算法即可擷取XML文件中的資料,
可以ransom的方式存取tree上任一節點的資料
SAX (Simple API for XML)


Event-driven
Serial的方式取得XML資料
27
Intelligent Healthcare System and Software Engineering Lab.
6. 服務的介面與實作
 WSDL


Interface description
Implementation description
28
Intelligent Healthcare System and Software Engineering Lab.
Interface Description
 Types
 定義訊息欲傳送時使用的資料類型
<types>
<s:schema>
<s:element name="GetPlaneResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetPlaneResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" type="s:string" />
</s:schema>
</types>
29
Intelligent Healthcare System and Software Engineering Lab.
Message 範例
 代表一個網路服務的細節抽象概念,訂一單向的訊息
內容

每個Message包含1~N個part元素
<message name=“AirLinesRequest">
<part name="symbol" type="xsd:string"/>
</message>
<message name="AirPlaneResponse">
<part name=“flight" type="xsd:string"/>
</message>
31
Intelligent Healthcare System and Software Engineering Lab.
 PortType
 定義一連串傳送接收的作業(operation),並對
應要傳送的訊息(message)
 抽象的方式指出這個網路服務在做什麼
 一個operation定義了input和output
consumer
provider
32
Intelligent Healthcare System and Software Engineering Lab.
PortType範例
<portType name=“FindAirFlightService">
<operation name="getFlight">
<input message="tns:SingleDateRequest"/>
<output message="tns:AirFlightResponse"/>
</operation>
</portType>
33
Intelligent Healthcare System and Software Engineering Lab.
 Binding
 定義訊息如何透過網路傳送,即operation如何
被呼叫,和哪種的通訊協定做繫結



SOAP Binding
HTTP Get/Post Binding
MIME Binding
34
Intelligent Healthcare System and Software Engineering Lab.
Binding範例
<binding name=“AirPlaneBinding" type="tns:FindAirFlightService">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getFlight">
<soap:operation soapAction="http://www.getFlight.com/GetFlight"/>
<input>
<soap:body use="encoded" namespace="urn:AirLinesFlight"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
資料型態的編碼規則
<output>
<soap:body use="encoded" namespace="urn:AirLinesFlight"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
35
Intelligent Healthcare System and Software Engineering Lab.
Implementation Description
 主要說明如何執行由Interface Description所提供的服
務,包含兩項目

Service


描述一個網路服務所有可能之作業端點的部屬細節
Port


是Service的子元素,不能單獨存在
提供服務的URL,代表外部可以和此Service溝通
的進入點
36
Intelligent Healthcare System and Software Engineering Lab.
 範例
<service name=“AirFlightService">
<documentation>Air Flight Service</documentation>
<port name=“GetFlightServicePort" binding="interface:AirFlightBinding">
<documentation>
Get Air Flight Service
</documentation>
<soap:address location="http://www.air.com/airflightservice"/>
</port>
</service>
37
Intelligent Healthcare System and Software Engineering Lab.
服務 [ Service ]
連接埠 [ Port ]
連接埠 [ Port ]
連接埠型態 [ Port type ]
A 操作 [ Operation ]
A Message(輸入)
連接埠型態
[ Port
type ]
B Message(輸出)
B 操作 [ Operation ]
C Message(輸出)
鏈結一
[ Binding ]
鏈結二
[ Binding ]
鏈結三
[ Binding ]
網路位址
38
Intelligent Healthcare System and Software Engineering Lab.
7. 服務的品質(Quality of Service,
QoS)









Availability
Accessibility
Conformance to standards
Integrity
Performance
Reliability
Scalability
Security
Transactionality
39
Intelligent Healthcare System and Software Engineering Lab.
8. 結論
 服務導向架構(SOA)改變傳統的軟體開發模
式
 透過SOA 與 web service,使得使用者不再侷
限單一的作業平台,能夠更有效的達到跨平台
的作業環境
 有效率的服務整合方法是未來的發展目標
40