Top Banner
XML, Web Services and Middleware 國國國國國國國國 國國國國國 國國國 [email protected]
88

XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 [email protected].

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

XML, Web Services and Middleware

國立台灣師範大學資訊教育系葉耀明

[email protected]

Page 2: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

內容大綱• 第二代 Web 與 Component Software• 何謂 Middleware• Middleware 的演進• CORBA 的概念• Web Service 的概念• Web Services 的發展過程• Web Services 的架構• SOAP• WSDL• UDDI• Web Service 與 ebXML• Web Services 的應用• 台灣的殺手級應用: e-Taiwan 計畫• 總結

Page 3: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

網路發展過程• 1960- :網路源起

– Bitnet, IBM Network ( 獨立網路 )

– ARPANET: TCP/IP (1968-)

• 1980- : Internet– WAN : TCP/IP ( 網路進入網網相連時代 )

– LAN : Ethernet, Token Ring

• 1990- : World-Wide Web( 第一代 )– HTML (1989-) ( 網路進入多媒體時代 )

• 2000- : World-Wide Web( 第二代 )– XML (1998-) ( 網路進入自動化資訊處理時代 )!!!

– Web Services (2001-) ( 程式獨立於網頁之外 )

Page 4: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

下一代全球資訊網 ( 一 )• 全球性網路整合知識庫• 全球性網路整合服務

webdata

webservice

webdata

webdata

webservice

webdata

webservice

webdata

webdata

Page 5: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

下一代全球資訊網 ( 二 )• 第一代 Web: HTML

– 網頁資訊 Web Data (for human)

• 第二代 Web: XML– Web Data: Semantic Web (XML 網頁 ) 可形成整合知識庫的知識網頁

• XML Schema/RDF/OWL (for human & machine)

– Web Service: 可透過網路動態整合的網路服務Web program, Web software (XML 訊息 )

• SOAP/UDDI/WSDL (for human & machine)• Software in a nodeSoftware integrated through Web

Page 6: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

中介軟體 Middleware 的概念

• Middleware 的定義• 起源:

– 主從架構技術: RPC

• Intranet Middleware:– CORBA/DCOM/RMI

• Internet Middleware:– Web Service

Page 7: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Types of Distributed Processes• Peer-to-Peer

– Send/Receive– Role: no– Application: MP3 exchange

• Filter– Receive/Forward– Role: calling/filter/called– Application: Router, Proxy Server

• Client/Server– Request/Reply (or Response)– Role:Client/Server– Application: WWW, MIS, Agent…

• Multicast– Multicast/response– Role: Coordinator/Partner– Application: B2B Collaboration, Media

Distribution

A B

BA C

A B

send receive

sendreceive

filtercalling called

request

replyclient server

A B

B

Bmulticast

reply

calling

coordinator

partner

Page 8: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Type of Client/Server System

• Desktop client – Traditional client/server

• Intrasystem client/server – DDE (Dynamic Data Exchange) Server– Browser/Personal Web Server

• Desktop server – X-terminal

Page 9: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Client/Server Architecture

• 3 Layer Architecture

Hardware

AP

OS

Hardware

AP

SystemServices

Hardware

AP

SystemServices

Fundamental APClient/Server AP

Client Server

Page 10: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Middleware 的定義• Middleware: a layer of software whose purpose is to mask heterogeneity and to

provide a convenient programming model to application programmers. • Middleware[Renaurd]: 提供 control integration ,做 data management,

communication management, object management

Hardware

AP

Hardware

AP

Client/Server AP

Client Server

OS OS

Middleware MiddlewareAPI API

Protocol

註: Application Program Interface

Page 11: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Application Framework

Computer and Communication Facility

System Service

Data Repository

Control Integration

Task Management

Presentation Interface

User Interface

Hardware

Enterpriseware

Middleware

Userware

APPLICATION

Page 12: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Middleware Framework Foundation Components

Computer and Communication Facility

System Service

Data Repository

Control Integration

Device Driver

Operating System

System API

Network Layer

Transport Layer

Session Layer

RPC

Federated Distributed Data Base

DataManagement

CommunicationManagement

ObjectManagement

Page 13: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

OSI 7 LayersApplication Layer

應用層 Presentation Layer

表現層 Session Layer

交談層 Transport Layer

傳輸層 Network Layer

網路層Data Link Layer

資料鏈結層 Physical Layer

實體層 raw bit stream

data conversion

routable packet

data frame

end-to-end delivery

connection service

network service

Socket

TCP, UDP

IP

Ethernet MAC

Ethernet Base-band

ORB

RPC

RPC

RPC

Page 14: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Procedure Call 的發展• Procedure Call

– Pascal, C– Compiler provides mechanisms

• Inter-Process Communication (IPC)– C– OS provides service

• Remote Procedure Call (RPC)– ODBC, HTTP/HTML– Middleware provides service

• Object-Oriented Remote Procedure Call (OORPC)– CORBA(IIOP, GIOP), DCOM

• XML-based Remote Procedure Call (XML-Based RPC)– XML-RPC (Remote Procedure Call)– SOAP (Simple Object Access Protocol)– WDDX (Web Distributed Data Exchange)

Page 15: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Procedure Call

• Process 內的 Procedure Call– Same Address Space– Pascal, C– Compiler provides mechanisms

• Procedure name linking

• Parameter binding

• Variable Stack

Process

Main(){…

call pc(a,b,c);

…}

Procedure pc(x,y,z){…Return(z=result);}

Page 16: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Inter-Process Communication (IPC)

• Node 內的 Procedure Call– Same Operating System– C; SVC (supervisor call)– OS provides service

• Process IDProcedure name

• Message Passing

• Send/Receive

Process AMain(){…

send(pid,a,b);

receive(pid,c);

…}

receive(pid,x,y))…send(pid,z);

Process B

Page 17: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

RPC (Remote Procedure Call)

• 用 RPC 做 concurrent process 由 White 1976 提出

• Node 間的 Procedure Call– Different Operating System– VB, Delphi, VC++, ODBC– Middleware provides service

• NodeIDProcess IDProcedure name• Message Passing• Request/Reply

Page 18: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

RPC ProtocolClient Process

Main(){…

call rpc(a,b,c);

…}

RPC Library

STUB: rpc(a,b,c){

send((x=a,y=b),server)

Receive(c=z,server)

Return(c);

}

Server Process

RPC Library

HARNESS: Main(){

Receive((x,y),client)

Call rpc(x,y,z);

Send(z,client)

}

Application

Procedure rpc(x,y,z){…

Return(z=result);

}

Request

Reply

Page 19: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Client/Server Communication 的特性

• Client 特性:主動者– GUI

• Server 特性:被動者– Data Processing, Computing, . . .

• Communication 特性:– Transactional:

• atomic: 原子性• consistency: 一致性• isolation: 獨立性• serialization: 循序性• durability: 永久性

– Cooperative: not master/slave

Page 20: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

RPC ISSUES• Connection: 連線方式

– Connectionless 封包式 : datagram(packet switched)– Connection-oriented 連線式 :datastream(circuit

switched)• Addressing: 位址取得

– Name resolution: 名稱解讀– Dynamic binding: 動態連結

• Synchronization: 同步方式• Failure Handling :容錯處理• Security :安全• Data Conversion ;資料格式轉換

Page 21: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Connection Issues

• Circuit switching: connection-oriented– 電話網路 ,

• Packet switching: connectionless– TCP/IP

• Hybrid: – connectionless(low level) + connection-

oriented(high level) – ATM

Page 22: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Connection Issues特性 connection-

orientedconnectionless

message type datastream datagram

routing Static Dynamic

message addressing

full destination address to establish circuit; circuit ID only

broadcast to all nodes to full destination address to specific node

reliability sequenced,error control, flow control, delivery guaranteed

no guaranteed;message can be lost or arrive out of order

option can be negotiated during setup

N/A

synchronization overhead

circuit setup and release

Message routing

Page 23: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Addressing Issues

• by name: object X

• by address: object at location x

• by content: object with value x

• by route: object found at end of path x

• by source: all my objects

• broadcast identifier: all objects of type x

• group identifier: all objects related to x

Page 24: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Static Binding • Internet 較低階部份用 static binding (compile time) • global name:

– network+subnetwork+host+process-id+name – internet domain name: [email protected] e.g. [email protected]– 有時加上 hostname eg: [email protected]

TCP/IP layered naming context

socket context

network context

datalink context

server nameport (8 bit)

portIP address (32 bit)

IP addressEthernet address (48 bit)

Page 25: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Dynamic Binding

• client/server 較高階部份用 (run time) • via convention: 用 configuration convention

– 用 environment variable: set MYSERVER=123456

– 用 configuration file: 含 global name table

• via broadcast: 提供 name resolution service– Microsoft NetBEUI(NetBIOS Extended User

Interface) 網路上的芳鄰 • via name server

– Novell SPX/IPX

Page 26: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Microsoft NetBEUI(NetBIOS Extended User Interface)

Client Local NetBIOS Remote NetBIOS Server

ADD.NAME “client21” Update Name Table

Send(Client21 at address21”,,broadcast)

Update Name TableUpdate Name TableSend(“Server4 at address46,broadcast)

ADD.NAME “Server4”

Update Name Table

CALL “Server4”

LISTEN

Session Starts

Lookup NameSend(Session1,Address46)

Receive

Receive

Lookup NameSend(Reply,address21)

ReceiveSession 1Process message”Send “Reply”,”client21”HANGUP

Lookup NameSend(Request,Address46,Session1)

Session StartsSEND“Request”, ”Server4”RECEIVESession1Process MessageHANGUP

Page 27: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Novell SPX/IPX Client@987654 Bindery Server@123456

ScanBindery “GreateServer”

AdvertiseServer “GreatServer”

IPXOpenSocket

Address 123456

Socket 78Address 123456

IPXGetLocalTarget

Socket 78

IPXSendPacket[(0,123456,78),(0,987654,32),Request] IPXReceive

Process Message

IPXSendPacket[(0,987654,32),(0,123456,78),Reply]

Page 28: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Synchronization Issues

• blocking protocol: – blocking send/blocking

receive :synchronized– strict RPC

• nonblocking protocol: – nonblocking send/nonblocking receive– master/slave: rendezvous model

Page 29: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Master/slave Server process Client Process

Main(){… call rpc(a,b,c);…}

RPC LibrarySTUB: rpc(a,b,c){send((x=a,y=b),server)Receive(c=z,server)Return(c);}

Server ProcessMASTER: Loop( ) {receive((x,y),client) spawn slave(x,y,client)}

ApplicationProcedure rpc(x,y,z){…Return(z=result);}

Request

Reply

SLAVE:{ call rpc(x,y,z); send(z,client)

}

Page 30: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Failure Modes

• client call 後 crash:– 處理 : client discard message

• message lost:– 處理 : 用 ACK, timeout, resend: three-packet

protocol: request, reply, ACK– no-more-than-once RPC semantics: 用 sequence

number 控制 server resend• server crash:

– 處理 : (1)client resend call, retry 幾次後,依靠server callback 或 user abort request

– (2)server 做 atomic-transaction service• server lost message

Page 31: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Three-Packet Protocol

Client Process

Main(){… call rpc(a,b,c);…}

RPC LibrarySTUB: rpc(a,b,c){Inc RPC Sequence No.send((x=a,y=b),rpc)receive(c=z,server)if (Timeout(receive)) retry else send(ACK,rpc)

Server ProcessRPC LibraryHARNESS: Main(){Receive((x,y),client)Check rpc Sequenceif Sequence > Last Msgcall rpc(x,y,z); }

ApplicationProcedure rpc(x,y,z){…Return(z=result);}

Request

Reply

Inc Last Msgsend(z,caller)receive(ACK,caller)if (Timeout(receive))resend(z,caller)

ACK

resend

Page 32: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

CORBA (Common Object Request Broker Architecture)

由 OMG (Object Management Group)所制定的分散式物件標準規格

目前為 CORBA 3.0 介面定義語言 (IDL; Interface Definition

Language) 讓各種語言所寫成的物件可以達到共用的目的

以 ORB (Object Request Broker) 為物件間溝通的管道

Page 33: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

CORBA Architecture

CORBA ORB

Application Objects Common Facilities

Event LifeCycle TimeNaming

Common Object Services (16)

... ...

Query

Page 34: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

CORBA 架構

CORBA ORB

Client Stub Server Skeleton

IDL

Java

IDL

C++

IDL

AdaJava C++ Ada

Page 35: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Services 的發展過程• SOAP 發展:

– XML-Based Remote Procedure Call: Loosely-Coupled Distributed System– XML-RPC: Userland– WDDI: WebMethod– SOAP:Microsoft– SOAP 1.2: W3C (Web 基礎建設的一環 )

• UDDI/WSDL 發展– UDDI 協會:產業電子目錄

• Microsoft, IBM, Ariba– Basic SOA (Web Services 基礎架構 )

• Web Services 發展: SOA (e-Business 主軸技術 )– OASIS 協會:和 ebXML 整合– WS-Security– WS-Reliability– WS-Choreography– WSDM (Distributed Management)

Page 36: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Services 技術概念:SOA: Services Oriented Architecture

UDDI

WSDL

Service Broker

ServiceRequester

ServiceProvider

Publish Request

Bind and Request

Reply

SOAP

UDDI 2.0: Universal Description, Discovery and Integration (2001/6)WSDL: Web Service Description LanguageSOAP: Simple Object Access Protocol (2001/7)

新型態的入口網站: - 給程式 (Web Service) 用的

Page 37: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Basic Web Services Stack

Transport Network

XML Messaging

Service Description

Service Publication/Discovery

HTTP,SMTP,FTP over TCP/IP

SOAP

WSDL

UDDI

Page 38: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

一個 Web Service 是什麼 ?

• Some software functional block– Location, platform, code are irrelevant

• “Loosely coupled software components that encapsulate discrete functionality and that are accessible over standard Internet protocols.”—The Stencil Group

• “Web Services are a new breed of web application. They are self-contained, self-describing, modular applications that can be published, located, and invoked across the Web.”– IBM

• Web 服務的提供者; Web 的主要居民• 資訊系統的動態組件

Page 39: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Service-Oriented Architecture:Conceptual Model

Platform

Network/Transport

Core XML Standards

Partner Profiles

Reliable Messaging

Business Process-Workflow

Registry/Repository

Business Content

Industry Vertical Content

Universal Business Content

Sec

urity

Man

agem

ent

Technical Infrastructure

Standards

Business orApplicationStandards

Page 40: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Architecture of Web Services :Extended SOA

XML

SOAP

Messaging/Wire(Invocation)

WS

-Atta

chm

ents

(D

IME

)

WS

-Rel

iabi

lity

WS

-Rel

iabl

e M

essa

ging

WS

-Add

ress

ing

Structure (XML Schemas)

Service Description (WSDL)

Description

Semantic Web

RDF (meta data)

Process Flow and Pattern Description(Workflow, Orchestration, Transaction,

Policy, Portal)

Inspection (WSIL)

Directory (UDDI)

Discovery

WS-Security(Federation, Trust,

Conversation, SecurityPolicy)

ManagementWSDM

Page 41: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Services Implementation

UDDIRegistry

Web Server

WSDL

SOAP over HTTP

Web ServicesClient Web Service

Runtime

Business FunctionalityWeb Services

System

SOAP

Service Discovery Service Publish

Service Description

Page 42: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Service 的運作模式• 兩種 Web Service 型態

– Message Producer• 做服務動作和加內容到訊息內

– Message Consumer• 取用訊息內容和做服務動作

• Pipeline : message flow– Pipeline is a sequence of services

• Messages grow and shrink on the way

Page 43: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Services 的發展類型• Enterprise Web Services

– 新型態的 EAI (Enterprise Application Integration)– 使用技術: LAN+SOAP+WSDL

• Internet Web Services– 新型態的 B2Bi (Business to Business Integration)– 使用技術: Basic SOA

• SOAP+UDDI+WSDL• Internet Security

• Semantic Web Services– Integrated e-Business (Global e-Marketplace)– 使用技術: Extended SOA

• SOAP+UDDI+WSDL• WS-Security+WS-Reliability+WS-Choreography+WSDM

– 整合 Semantic Web Architecture• RDF+OWL+XTM(XML Topic Map) …

Page 44: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Business Collaboration Through Web Service Integration

Workflows ERP

Data Repository

EAI

Components

Business Partner 1

Wrap intra-enterprise Application

Web Services

Workflows ERP

Data Repository

EAI

Components

Business Partner 2

Wrap intra-enterprise Application

Web Services

Communication LayerSOAP,HTTP,FTP,SMTP

Content LayerWSDL,ebXML,Rosettanet

Business Process LayerWSFL,XLANG,ebXML,

Rosettanet

B2B Interactions

Page 45: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Service 電子化企業協同合作架構圖

Page 46: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Invocation: SOAP

XML

SOAP

Messaging/Wire(Invocation)

Att

achm

ents

(bi

nary

)

Qos

Rel

iabl

e M

essa

ging

Sec

urit

y

Con

text

/Pri

vacy

Tra

nsac

tion

s

Rou

ting

in

term

edia

ries

Page 47: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Why XML-Based RPC ?

COM/CORBA Client or Server

XML-Based RPCClient or Server

Server (WEB) Server

HTTP: port 80

Page 48: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Tightly-Coupled System v.s. Loosely-Coupled System

• 平行處理系統– Tightly-Coupled System : Shared memory, Synchronous

– Loosely-Coupled System : Distributed memory, Asynchronous

• 分散式系統– Tightly-Coupled System : LAN-based Distributed System

• CORBA, DCOM

– Loosely-Coupled System : Web-based Distributed System• XML-RPC • SOAP

Page 49: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Tightly Coupled Distributed System

Server1 Server2

Request

Reply

GetCurrency(country)

Request

Reply

GetExchangeRate(currency)

Request

Reply

SubmitExchange(amount,currency)

Page 50: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Loosely Coupled Distributed System

Server1 Server2

Request

<method> GetCurrency(country) GetExchange(currency) SubmitExchange(amount,currency)</method>

Reply

<response> reply data …</response>

Page 51: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

傳統 RPC v.s. Web-Based RPC(SOAP)

• RPC:– (typically) binary

representation– protocol model– transport dependent– programming language

centric– not extensible– secure– robust– not easily transformed

• It’s implementation-centric

• XML:– text representation

– document/message model

– transport independent– language independent– extensible– not secure (yet)– not robust– easily transformed

• It’s application-centric

Page 52: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

SOAP

• Simple Object Access Protocol – a lightweight protocol based on XML– W3C Notes (2000/5/8)(Microsoft 主導 , Userland)– SOAP Version 1.2: W3C Recommendation(2003/6/24)– Part 0: Primer– Part1: Messaging Framework– Part2: Adjuncts

• 升級版的 XML-RPC– 改善 Verbosity( 冗言 )– 改善 Data Typing

Page 53: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

SOAP Message

Client Process Server Process

Envelope

MessageHeader

MessageBody

(Payload)

Envelope, body (payload) and header defined

in XML

Main(){… call rpc(a,b,c);…}

RPC LibrarySTUB: rpc(a,b,c){send((x=a,y=b),server)Receive(c=z,server)Return(c);}

RPC LibraryHARNESS: Main(){Receive((x,y),client)Call rpc(x,y,z);Send(z,client)}

ApplicationProcedure rpc(x,y,z){…Return(z=result);}

Page 54: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

SOAP 範例: RPC

• PlaceOrder([in] Title string, [in] Author string, [out] DaysToDelivery integer);

Page 55: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

SOAP 範例: Request• The request message in HTTPPOST /BookServer HTTP/1.1

Host: www.quickbooks.com

Content-Type: text/xml

Content-Length: nnnn

SOAPMethodName: Some-Namespace-URI#PlaceOrder

<SOAP:Envelope xmlns:SOAP=“urn:schemas-xml-xmlsoap-org:v1?gt;”>

<SOAP:Body>

<m:PlaceOrder

xmlns:m=“Some-Namespace-URI?gt;”>

<Title>Happy All The Time</Title>

<Author>Laurie Colwin</Author>

</m:PlaceOrder>

</SOAP:Envelope>

Page 56: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

SOAP 範例: Response

• The reply message in HTTPHTTP/1.1 200 OK

Connection: close

Content-Type:text/xml

Content-Length: nnnn

<SOAP:Envelope xmlns:SOAP=“urn:schemas-xmlsoap-org:soap.v1?gt;”>

<SOAP:Body>

<m:PlaceOrderResponse xmlns:m=“Some-Namespace-URI?gt;”>

<return>1</return>

<DaysToDelivery>7</DaysToDelivery>

</m:PlaceOrderResponse>

</SOAP:Body>

</SOAP:Envelope>

Page 57: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

WSDL Structure

Binding

PortType

Messages

Types

Service

Port

Abstract Definition

(Reusable Part)

Implementation

Specific

Page 58: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

WSDL Working Mechanism

Application(client, server)

PublishedWeb Service

WSDL

SOAP

Obtain WSDL

Page 59: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Service Description: WSDL Documents

• Types: structure types of data

• Messages: logical messages

• Operations: messages group (unit of work)

• Port types: operations group

• Bindings: operation protocol

• Ports: binding with protocol-specific address

• Services: collection of ports

Page 60: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

WSDL Document(1): Abstract Definition<definitions><types>

[XML Schema describing the used datatypes]</types><message>

[Description of message]</message><portType>

<operation><input>…</input><output>…</output><fault>…</fault>

</operation></portType><binding>

[Description of network protocol for invocation]</binding> . . .</definition>

Page 61: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

WSDL Document(2): implementation

<definitions>

<service>

<port>

[Reference to actual location of service]

</port>

</service>

</definitions>

Page 62: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

WSDL Transmission Primitives

• One-way Operation

• Request/Response Operation

• Solicit/Response Operation

• Notification Operation

Page 63: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

One-way Operation

<portType name=“submitOrderType”><operation name=“submitOrder”> >

<input message=“SubmitOrderInput”/></operation>

</portType>

Client Service endpoint

One-way input

Page 64: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Request/Response Operation<portType name=“ItemDescriptionType”>

<operation name=“GetItemDescription”/> <input message=“ItemDescriptionRequest”/><output message=“ItemDescription”/>

</operation></portType>

Client Service endpoint

Request (input)

Response (output)

Page 65: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Solicit/Response Operation

<portType name=“OrderStatusType”><operation name=“SendOrderStatus”/>

<output message=“OrderStatus”/><input message=“OrderStatusReceipt”/>

</operation></portType>

Client Service endpoint

Solicit (output)

Response (input)

Page 66: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Notification Operation

<portType name=“NotificationType”><operation name=“Notification”/>

<output message=“NotificationMessage”/></operation>

</portType>

Client Service endpoint

Notification (output)

Page 67: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Discovery: UDDI

Inspection

Directory (UDDI)

Discovery

Page 68: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Working Mechanism

UDDIRegistry

Service Publication LayerService Discovery Layer

Application(client, server)

PublishedWeb Service

WSDL

3. SOAP Messages

Service Description Layer

1. Publishes WSDL Information2. Obtains WSDL Information

XML messaging & Transport Layer

Page 69: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Service

UDDI Business Structure

Business

Service

Technical Specification

Page 70: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Registry Data

• Businesses register public informationabout themselves

• Standards bodies, Programmers, Businesses register information about their Service Types

WhitePages

YellowPages

GreenPages

Service TypeRegistrations

Business Units

Taxonomies

Descriptions of Services

Page 71: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Data Structures

Page 72: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Business Entity(1)

<businessEntity><discoveryURL>

[URL returning related document about business]</discoveryURL><name>

[business name]</name>

. . .</businessEntity>

Page 73: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Business Entity(2)<businessEntity>

. . .<contact>

<personName>[Name of contact

person]</personName><email>

[email address]</email><address>

<addressLine> [address information]</addressLine>

</address></contact>

</businessEntity>

Page 74: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Business Service(1)<businessService><name>

[service name]</name><description>

[service description]</description><bindingTemplate>

<description> …</description><accessPoint>…</accessPoint><tModelInstanceDetails>…</tModelInstanceDetails>

</ bindingTemplate>. . .

</businessEntity>

Page 75: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI Business Service(2)

<businessService>. . .

<categoryBag><keyedReference>

<keyName>…</keyName><keyValue>…</keyValue><tModelKey>

[taxonomy, one of 4 predefined keys, e.g. UUID]

</tModelKey></keyedReference>

</categoryBag></businessEntity>

Page 76: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI tModel

<tModelInstanceDetails><tModelInstanceInfo>

<tModelKey>…</tModelKey><description>…</description><tModelDetails>

<overviewDoc>…</overviewDoc><instanceParms>…</instanceParms>

</tModelDetails></tModelInstanceInfo>

</tModelInstanceDetails>

Page 77: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

UDDI API• Inquiry API

– Find things• find_business

• find_service

• find_binding

• find_tModel

– Get Details about things• get_businessDetail

• get_serviceDetail

• get_bindingDetail

• get_tModelDetail

• Publishers API– Save things

• save_business

• save_service

• save_binding

• save_tModel

– Delete things• delete_business

• delete_service

• delete_binding

• delete_tModel

– security…• get_authToken

• discard_authToken

Page 78: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

.NET PlatformVisual Studio .NET

.NET Enterprise Servers .NET Framework

.NET Building Block Services

Operating System on Servers, Desktops, and Devices

Web Services Web Forms Windows Forms

Data and XML Classes

Base Classes

Common Language Runtime (CLR)

Page 79: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Java Platform

• JAXM: – Java API for XML Messaging

• JAXR: – Java API for XML Registries and

Repositories– uddi4j, wsdl4j: IBM

• JAXP:– Java API for XML Processing– Xerces: Apache

• JAX-RPC:– Java API for XML based Remote

Procedure Calls

• JAXB:– Java Architecture for XML Binding

Page 80: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Java Platform: Sun ONE

Platform

Identity and Policy

Service Container

ApplicationsAnd

Web ServicesServiceDelivery

ServiceIntegration

Service Creation and Assembly

Any

Device

Backend

System

Page 81: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

Web Services 應用• Business Information with rich content

– Weather reports - Credit check– News feed - Credit card validation– Airline schedules - Request for quote– Stock quotes - Auctions

• Transactional Web Services for B2B or B2C– Airline reservations - Supply chain management– Rental car agreements - Purchase order processing

• Business Process Externalisation– Business linkages at a workflow level– Allows complete integration at a process level

Page 82: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

台灣在 XML 的導入應用• 電子化公文系統:行政院研考會 (1999-2001) (XML, DTD)• B2B 電子商務計畫:經濟部 (1999-)

– A 計畫、 B 計畫:資訊流 (Rosettanet) 電子業 B2B– C 計畫:金流 – D 計畫:物流– E 計畫:協同設計– 產業電子化標準計畫:傳統產業 B2B

• E-Taiwan 共通平台計畫:行政院研考會 + 各單位 (2002-2008) (Web Services)

• 國家型數位學習計畫:國科會 (2002-2007) (SCORM)• 國家型數位典藏計畫:中研院 (2000-)(Dublin Core)• 註: IPv6 建置發展計畫:交通部電信總局 (2003-2007)

Page 83: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

台灣 e 化: e-Taiwan

• 台灣的 G2G 、 G2B 、和 G2C 基礎建設– 2002-2007

• 政府單一入口網站

•政府目錄服務: Web Service(UDDI/WSDL)

• 共通作業平台: Web Service(SOAP)

Page 84: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

政府單一入口網站

Page 85: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

政府目錄服務整體架構全國政府機關目錄服務

GDS

跨機關目錄服務X-GDS

跨機關應用目錄服務X-APDS

討論區服務討論區服務

全國政府機關電子公佈欄服務全國政府機關

電子公佈欄服務

網路電話服務網路電話服務

網路安全通報網路安全通報

主計人員服務網主計人員服務網

其他應用服務其他應用服務

GCAGCA

組織U-GDS

機關U-APDS

機關 A 機關 B

X-GDS Update Module DMS-2

DS維護人員

Page 86: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

共通作業平台

Single Sign-On

BrowserInterface

Service Flow

Hand PhoneInterface

PDAInterface

KioskInterface

WebService

Repository戶役政

Gateway稅務

Gateway地政

GatewayAuthorizationWeb Service

AccountingWeb Service

AuthenticationWeb Service

Context

Gateway Services

UserProfile

Common Services

XMLMetadata

目錄

登錄機制

Publish

LegacySystem

認證

授權

ServiceAccounting

XML / HTTP

監理Gateway Gateway

Gateway

工商Gateway

Service Execution Environment(Session/Transaction/Event Handling)

PaymentWeb Service

DigitalSigniture

DocumentWeb Service

MessageWeb Service

LegacySystem

LegacySystem

ServiceServer

ServiceServer

ServiceServer

Gateway

GRCA

Bank

Service Flow Service Flow Service Flow

OrganizationWeb Service

User ProfileWeb Service

GCA內政部 CA

認證機構

金融機構

資料來源 : 資策會

GDS

ServiceServer

工商 CA

OID註冊

Page 87: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

導入 36項便民網路服務• 92年規劃項目 (2003)

– 交通監理– 公司登記

• 93年規劃項目 (2004)– 觀光旅遊– 就業服務– 戶政服務– 醫療服務

Page 88: XML, Web Services and Middleware 國立台灣師範大學 資訊教育系 葉耀明 ymyeh@ice.ntnu.edu.tw.

總結• 第二代全球資訊網已經來臨

– XML 技術平台即為主流的 Web 技術平台– Browse the Web Program the Web– XML 技術基礎平台已經成熟 (1998-2003)

• 下一波的主流資訊技術發展重點– Service Oriented Architecture (2001-2005?or 2007?)

• Basic SOA (1999-2003)• Extended SOA (2003-2005?or 2007?)

– Semantic Web Architecture (2001?-2010?)• Bottom-Layer: RDF (1999)• OWL/XTM/DAML-OIL . . .

• 第二波 .COM熱潮: Global e-Marketplace– 2005? 2007?– ebXML (Web Service)– 3G+WLAN– PKI (G2G, G2C, B2B)