Enterprise JavaBeans 2.0

thingyvirginiaInternet και Εφαρμογές Web

30 Ιουλ 2012 (πριν από 4 χρόνια και 10 μήνες)

346 εμφανίσεις

30 Aug

200
5

WebSphere TopGun School

黃昭棋
, Brouse

brouse@webcomm.com.tw

Web Services
系統整合技術

與開發實務

30 Aug 2005

WebSphere TopGun School











為什麼我們需要

Web Services ?


什麼是

Web Services
的核心技術

?


什麼是

Web Services
的技術前沿

?


我可以怎麼開始建構

Web Services ?


如何實作一個

Web Services ?



<<
一個
坥戠卥牶楣敳
架構下的投資理財管理系統

為例


結論與討論

30 Aug 2005

WebSphere TopGun School

創新服務的需求日益增加
……………

店頭市場

電話市場

HTTP

網路市場





30 Aug 2005

WebSphere TopGun School

Web Services
要解決什麼問題


ⴭⴭⴭ


資訊孤島”

30 Aug 2005

WebSphere TopGun School

為什麼使用

? …… Web Services

Service Requester

Service Provider

Service

Provider

Service

Provider

Service

Provider

30 Aug 2005

WebSphere TopGun School

系統整合為什麼青睞

Web Services?

Service Requester

Service Provider

Service

Provider

Service

Provider

Service

Provider

通信的成本

呼叫服務的成本

http

……
為了標準

……
為了標準後的平台與開發工具

SOAP Envelop

SOAP Message

HTTP Header

SOAP Body

SOAP Header

Headers

Message

SOAP

30 Aug 2005

WebSphere TopGun School

EJB

Business

Logic

Browser

Web Services
技術架構誕生

HTTP

<HTML>


<BODY>


</BODY>

</HTML>

HTML

DB

JSP

Presentation

Layer

EJB

Business

Logic

Application

Server

Interne
t

Web

Service

Runtime

SOAP

Router

Service

Proxy

getQuote( )

SOAP Envelop

SOAP Message

HTTP Header

SOAP Body

SOAP Header

Headers

Message

SOAP Envelop

SOAP Message

HTTP Header

SOAP Body

SOAP Header

Headers

Message







Modular

Described

Published

Found

Bound

Invoked

Composed

getQuote( )

SOAP Envelop

SOAP Message

HTTP Header

SOAP Body

SOAP Header

Headers

Message

SOAP Envelop

SOAP Message

HTTP Header

SOAP Body

SOAP Header

Headers

Message

Service

Registry

Service

Description

Find

Publish

Bind

Service

Requestor

WSDL+UDDI

Service

Service

Provider

Service

Description

WSDL+UDDI

30 Aug 2005

WebSphere TopGun School

Web Services
是企業能量的具體展現

店頭市場

電話市場

HTTP

網路市場





<SOAP
-
ENV:Envelope


xmlns:SOAP
-
ENV="..."


SOAP
-
ENV:encodingStyle="...">


<m:
getQuote

xmlns:m="my
-
ns">


<symbol>
2330

</symbol>


</m:getQuote >


</SOAP
-
ENV:Envelope>


<SOAP
-
ENV:Body>


<m:
getQuote

xmlns:m="my
-
ns">


<symbol>
2330

</symbol>


</m:getQuote >


</SOAP
-
ENV:Body>

<SOAP
-
ENV:Envelope


xmlns:SOAP
-
ENV="..."


SOAP
-
ENV:encodingStyle="...">


<m:
getQuote

xmlns:m="my
-
ns">


<symbol>
2330

</symbol>


</m:getQuote >


</SOAP
-
ENV:Envelope>


<SOAP
-
ENV:Body>


<ns1:
getQuoteResponse
>


<return>
42.50

</return>


</ns1:getQuoteResponse>


</SOAP
-
ENV:Body>

<?xml version="1.0" encoding="UTF
-
8"?>

<Quote Type="
台股


††††
<卹浢S氾2330<⽓祭bo氾

††††
<乡浥>
台積電
<⽎/浥m

††††




<Time>13:30</Time>


<Date>91/08/23</Date>

</Quote>

<Price>
42.50
</Price>

<html>


<title>
奇摩股市
</title>


<body>


<table >


<tr><th>
股票代號
㰯瑨㸠†††

††††††††
㱴搾㈳㌰
台積電
㰯瑤㸼⽴爾


<tr><th>
成交
㰯th㸠


<td>45.00</td></tr>


</table >


</body>

</html>


<tr><th>
股票代號
㰯瑨㸠†††

††††††††
㱴搾㈳㌰
台積電
㰯瑤㸼⽴爾

†††††
㱴爾<瑨t
成交
㰯<h㸠††


<td>42.50</td></tr>

30 Aug 2005

WebSphere TopGun School

企業核心價值
--
無遠弗屆的拓展

店頭市場

電話市場

加值整合市場

API ( )

HTTP

網路市場


應用服務如何
描述



應用服務如何
週知



應用服務如何
啟動



服務結果如何
呈現



服務結果如何
解讀



核心價值如何形成
服務


30 Aug 2005

WebSphere TopGun School

Web Services
三大技術主題

連結

安全

流程

30 Aug 2005

WebSphere TopGun School

SOAP overview

30 Aug 2005

WebSphere TopGun School

SOAP in a nutshell


An XML
-
based protocol with:


An envelope structure that contains a message


Encoding rules for data types


Rules for RPC requests and responses


Rules for exchanging messages using an underlying
protocol

30 Aug 2005

WebSphere TopGun School

HTTP

Servlet Container

App. Server

Http Request/Response

HTTP/1.1 200 OK

Server:

WebSphere Application Server/4.0

Content
-
Type:

text/html;charset=Big5

Cache
-
Control:

no
-
cache=“…"

Expires:

Thu, 01 Dec 1994 16:00:00 GMT

Content
-
Language:

zh

Transfer
-
Encoding:

chunked

<Html> …</HTML>

GET

/Requester/JSP/main.jsp HTTP/1.1

Accept:

*/*

Accept
-
Language:

zh
-
tw

Accept
-
Encoding:

gzip, deflate

User
-
Agent:

Mozilla/4.0

(compatible; MSIE 5.01; Windows NT 5.0)

Host:

localhost:84

Connection:

Keep
-
Alive

userID=1&StockID=2330

Post



Delete

Get

Post

Header

Option

Trace

30 Aug 2005

WebSphere TopGun School



Request and Response messages






SOAP specification defines an "envelope"


Request invokes a method on a remote object


Response returns result of running the method


"envelope" wraps the message itself


message is a different vocabulary


namespace prefix is used to distinguish the two parts

SOAP Message Structure

SOAP

Envelope

Application
-
specific
message vocabulary

SOAP envelope
vocabulary

30 Aug 2005

WebSphere TopGun School

POST /SOAP_Provider/servlet/rpcrouter HTTP/1.0

Host: localhost

Content
-
Type: text/xml; charset=utf
-
8

Content
-
Length: 500

SOAPAction: ""


<?xml version='1.0' encoding='UTF
-
8'?>

<
SOAP
-
ENV:
Envelope
xmlns:SOAP
-
ENV="http://schemas.xmlsoap.org/soap/envelope/"



xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance"


xmlns:xsd="http://www.w3.org/2001/XMLSchema">



<
SOAP
-
ENV:
Body>



<
ns1:
getStockQuote

xmlns:ns1="http://tempuri.org/lib.webservices.YahooStockQuote"


SOAP
-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">




<strSymbol xsi:type="xsd:string">
2330
</
strSymbol
>



</
ns1:
getStockQuote
>




</
SOAP
-
ENV:
Body>


</
SOAP
-
ENV:
Envelope>

A SOAP Request Message

SOAP

Envelope

30 Aug 2005

WebSphere TopGun School

A SOAP Response Message

SOAP

Envelope

<?xml version='1.0' encoding='UTF
-
8'?>

<SOAP
-
ENV:Envelope


xmlns:SOAP
-
ENV="http://schemas.xmlsoap.org/soap/envelope/"


xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance"


xmlns:xsd="http://www.w3.org/2001/XMLSchema">


<SOAP
-
ENV:Body>




<ns1:
getStockQuoteResponse



xmlns:ns1="http://tempuri.org/lib.webservices.YahooStockQuote"


SOAP
-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">


<return xsi:type="xsd:string">
68.5
</return>


</ns1:
getStockQuoteResponse
>



</SOAP
-
ENV:Body>

</SOAP
-
ENV:Envelope>



30 Aug 2005

WebSphere TopGun School

WSDL overview

30 Aug 2005

WebSphere TopGun School

W
eb
S
ervices
D
escription
L
anguage

Service

Implementation

Definition

Service

Interface

Definition

Service

port

Binding

PortType

Message

Type

A

B

1

2

3

4

30 Aug 2005

WebSphere TopGun School

Service Interface Elements


Reference to data type definitions (ex. XML schema)



Contains data type definitions for messages



Abstract definition of data being transmitted



Set of abstract operations with references to messages



Concrete specification for operations and messages



import




types




message




portType




binding

30 Aug 2005

WebSphere TopGun School

<portType name="YahooStockQuote">


<operation name=“getStockQuote">



<input message=" tns:getStockQuoteRequest "/>




<output message="tns:getStockQuoteResponse"/>




</operation>

</portType>

Import java.net.*;

:

public class YahooStockQuote{



public String getStockQuote(String strSymbol){


{


:


getHTML(strSymbol);


}


:

}

Service Interface Elements

2

<message name=" getStockQuoteRequest

">


<part name="strSymbol"



type="xsd:string"/>

</message>

<message name="setProxyResponse">


<part name="result"


type="xsd:string"/>

</message>

4

3

30 Aug 2005

WebSphere TopGun School

<binding name="YahooStockQuoteBinding"


type="tns:YahooStockQuote">





<operation name=“getStockQuote">





<input name="getStockQuoteRequest">






</input>


<output name="getStockQuoteResponse">






</output>


</operation>

</binding>

Service Interface Elements

1

<portType name="YahooStockQuote">


<operation name=“getStockQuote">


<input message=" tns:getStockQuoteRequest "/>


<output message="tns:getStockQuoteResponse"/>


</operation>

</portType>

30 Aug 2005

WebSphere TopGun School

<binding name=" YahooStockQuoteBinding

"


type=" tns:YahooStockQuote ">





<operation name=" getStockQuote ">





<input name=" getStockQuoteRequest ">






</input>


<output name=" getStockQuoteResponse ">






</output>


</operation>

</binding>

Service Interface Elements

<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<soap:operation soapAction="" style="rpc"/>

<soap:body


encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"


namespace="
http://tempuri.org/lib.webservices.YahooStockQuote
" use="encoded"/>


<soap:body



encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"


namespace="
http://tempuri.org/lib.webservices.YahooStockQuote
" use="encoded"/>

1

30 Aug 2005

WebSphere TopGun School

W
eb
S
ervices
D
escription
L
anguage

Service

Implementation

Definition

Service

Interface

Definition

Service

port

Binding

PortType

Message

Type

A

B

1

2

3

4

30 Aug 2005

WebSphere TopGun School

WSDL Document Types

Service

Port

import

Service
Implementation

Binding

PortType

Message

Type

import

Service
Interface

Binding

PortType

Message

Type

import

Service
Interface



Implementation of one or more service interfaces



Contains the endpoint reference





Abstract, reusable service definition



Represents a type of service that can be implemented




Service Implementation





Service Interface

30 Aug 2005

WebSphere TopGun School

<
binding

name="
YahooStockQuoteBinding
" type="
tns:YahooStockQuote
">


<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>


<operation name="getStockQuote">


<soap:operation soapAction="" style="rpc"/>


<input name="getStockQuoteRequest">


<soap:body


encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"


namespace="http://tempuri.org/lib.webservices.YahooStockQuote" use="encoded"/>


</input>


<output name="getStockQuoteResponse">


<soap:body


encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"


namespace="http://tempuri.org/lib.webservices.YahooStockQuote" use="encoded"/>


</output>


</operation>

<
/binding
>

<service name="
YahooStockQuoteService
">




<port binding="binding:YahooStockQuoteBinding“





name="YahooStockQuotePort">





<soap:address


location="
http://localhost:82/SOAP_Provider/servlet/rpcrouter
"/>



</port>


</service>

Service Implementation Elements

A

B

30 Aug 2005

WebSphere TopGun School

UDDI overview

30 Aug 2005

WebSphere TopGun School



A project to speed interoperability and


adoption for web services





Partnership among industry & business leaders


U
niversal
D
escription,
D
iscovery and
I
ntegration


Standards
-
based specifications for service


description and discovery


Shared operation of a web
-
based business registry





Initiated by Ariba , IBM and Microsoft


Now over 300 UDDI community members


30 Aug 2005

WebSphere TopGun School

Problems UDDI Solves

A mid
-
sized
manufacturer needs to
create 400 online
relationships with
customers, each with
their own set of
standard and protocols.

Broader

B2B

A flower shop in Australia
wants to be “plugged in”
to every marketplace in
the world, but doesn’t
know how

Smarter

Search

A B2B marketplace needs
to get catalog data for
relevant suppliers in its
industry, along with
connections to shippers,
insurers, etc.

Easier

Aggregation

Describe
Services

Discover

Services

Integrate

Them

Together

Provide a standards
-
based
profile for all electronic
services that are provided.
Includes web sites, other
electronic resources

Web Service


Visibility

Publish for

Accessibility

30 Aug 2005

WebSphere TopGun School

UDDI Registry

tModel

Registrations

Businesses

&

Services

How UDDI Works

2) Businesses
populate

the registry with

descriptions

of
the services they
support

3) UDDI manages each piece
of data using a unique
identifier key (either a
UUID

assigned by the
registry, or a user supplied
key)

4) Marketplaces,
search engines, and
business apps query the
registry to
discover

services at other
companies

1) Software
companies,
standards bodies
and programmers
populate the
registry with
references to these
specifications
(tModels)

5) Businesses use this
data to facilitate easier
integration

with each
other over the Web

30 Aug 2005

WebSphere TopGun School

Types of UDDI

Registries


Private Scope


EAI catalog (entry points, data, load balancing)


Catalog for approved suppliers of goods and services


Controlled access


Semi
-
Private Scope


Enterprise portal
-

catalog of products and services for public searching


Enterprise
-
only publishing


Industry
-
specific marketplaces


Invitation
-
only membership for publishing


Public, invitation
-
only, fee
-
based options for searching


Public Scope


Unrestricted access to all content


Provides a “root registry” for use by other “affiliated” registries (more on
this later)


Defines public business relationships between companies…


providers, suppliers, parents, subsidiaries, membership, certification

Many

Few

30 Aug 2005

WebSphere TopGun School

UDDI

Business

Registry

The UDDI Business Registry


Prototypical public UDDI
Registry


Peer nodes (websites)


Businesses register with any
operator


Registrations replicated
hourly


Complete set of “registered”
records available at all
operator nodes


Common set of SOAP APIs
supported by all operators


Compliance enforced by
business contract

Microsoft

SAP

IBM

NTT

30 Aug 2005

WebSphere TopGun School

Registry Data

White Pages

Yellow Pages

Green Pages

Service Type

Registrations



Businesses register


public information


about themselves




Standards bodies,


programmers,


businesses register


information about their


service


30 Aug 2005

WebSphere TopGun School

Yellow Pages

Green Pages

Service Type

Registrations

White Pages


List of multi
-
language text strings




Names, phone number,


fax numbers, web sites…



Business Name



Text Description




Contact info


Information about a

Service Provider

Registry Data

30 Aug 2005

WebSphere TopGun School

30 Aug 2005

WebSphere TopGun School

Green Pages

Service Type

Registrations

White Pages

Yellow Pages


Industry : NAICS


(Industry codes


US Govt.)


Product/Services : UN/SPSC(ECMA)


Location : Geographical taxonomy



3 standard taxonomies in V1

Business categories

Registry Data

30 Aug 2005

WebSphere TopGun School

30 Aug 2005

WebSphere TopGun School


References to specifications for Web services


Support for pointers to various file and URL


based discovery mechanism if required



Technical info about services,


specified by a business: how


to "do e
-
commerce" with them

How to bind to service
provider

Service Type

Registrations

White Pages

Yellow Pages

Green Pages

Registry Data

30 Aug 2005

WebSphere TopGun School

30 Aug 2005

WebSphere TopGun School

JAX
-
RPC(JSR101)

30 Aug 2005

WebSphere TopGun School

Java API for XML based RPC (JAX
-
RPC)


JSR 101: how Java developers use Web Services


Covers XML based RPC Web Services over SOAP (1.1)


Objective: Improved web service interoperability with
common standards



JSR 101 clients
<
--

> JAX
-
RPC compliant server



JAX
-
RPC server <
--

>

any SOAP
-
RPC client


30 Aug 2005

WebSphere TopGun School

Enterprise Web Services

(JSR109)

30 Aug 2005

WebSphere TopGun School

J2EE Web Services (JSR
-
109)


JSR
-
109 In a nutshell

J2EE Client Container
JAXRPC
Service Stubs
Application
J2EE Web Services
Container
Port
Service
Impl
Service
Def.
Interface
BIND
Service Registry
PUBLISH
FIND
Generated From
30 Aug 2005

WebSphere TopGun School

Static stub

30 Aug 2005

WebSphere TopGun School

關於
Web Services Connection



如果你只想記住三件事


定位:

技術:

應用:

Web Services
是由中央集權的

Web Application
進化到

地方分治

的系統整合技術

坥戠S敲癩捥猠
是三大

標準化

技術的集成



SOAP:

S
imple

O
bject

A
ccess

P
rotocol



WSDL:

W
eb

S
ervice

D
escription

L
anguage



UDDI:

U
niversal

D
escription

D
iscovery



and

I
ntegration

生產力

=
專業知識


操作工具

後標準化時代

的核心競爭力在於

創新的服務

30 Aug 2005

WebSphere TopGun School

Web Services

產業面臨的挑戰

理論上
:

Web Services


四輪傳動


精心設計
……

實際上
:


這時候,我們非常需要


四輪傳動
……

而且是


真正的四輪傳動。

30 Aug 2005

WebSphere TopGun School

Web Services
開發工具



WSAD, Visual Studio.Net, Forte…




坥戠卥牶楣敳S
主要開發工具



IBM, Sun, Microsoft, Oracle




坥戠卥牶楣敳S
執行環境提供者

30 Aug 2005

WebSphere TopGun School

Web Services
的特性



Services:
滿足
期望
的作為



Web Services:
滿足
眾人
期望的作為



經常

滿足「眾人」
遠比
滿足「期望」



具挑戰性

以麥當勞為例




Web Services
是以滿足眾人為前提的技術

Publish

Service

Provider

Service

Requestor

Service

Requestor

Service

Requestor

Service

Requestor

Service

Requestor

Service

Provider

Service

Provider

Service

Provider

Service

Provider

30 Aug 2005

WebSphere TopGun School

什麼不必是

Web Services ?



單純的

剁䌠⡒敭潴攠(灰汩捡瑩潮o䍡汬)


不是
坥戠卥牶楣敳



同一平台上的



不是
坥戠卥牶S捥s



它連

剥Ro瑥t
都談不上




同一語言開發下的

剁R

不必是
坥戠卥牶S捥猠



proprietary

call
即可

不必勞駕

协䅐



少數人使用的

剁R

不必是
坥戠卥牶S捥s



proprietary

IDL
即可

不必勞駕

坓䑌



多數人已知道的

剁R

不必是
坥戠卥牶S捥s



媒介機制已存在

不必勞駕

啄U䤠



殺雞不必用牛刀!


30 Aug 2005

WebSphere TopGun School

我該開始進行

Web Services !?


如果你對這問題應對自如
……



貴公司的產品是
坥W
-
b慳ad




也企圖對這問題侃侃而談
……



貴公司的產品是
坥W 卥牶S捥c
-
扡b敤




那麼請把這問題反問你的

platform Vendor



你的
委外廠商
(external)
以及你的
事業夥伴
⡩湴敲湡氩
……


當他們都有看法時,最適當的時機可能已經錯過



30 Aug 2005

WebSphere TopGun School

Web Services
技術總整理

XML

SOAP

ebXML

UDDI

Visibility

Trough of

Disillusionment

Slope of

Enlightenment

Plateau of

Productivity

Technology

Trigger

Real Peak of

Inflated

Expectations

Maturity

BPEL

WS
-
I

WSRP

Liberty

WS
-
Security

XACML

SAML

XML
Signature

XKMS

XML Encryption

WSDL

WS
-
Coordination

WS
-
Transaction

Key: Time to “plateau”

Less than two years

Two to three years

Three to five years

30 Aug 2005

WebSphere TopGun School