wsdl 1.1

27
WSDL 1.1

Upload: flavia-dorsey

Post on 02-Jan-2016

41 views

Category:

Documents


3 download

DESCRIPTION

WSDL 1.1. WSDL 1.1. 네트웍 상의 서비스를 기술하는 XML 문서 구성 types: 데이터 타입에 대한 정의 message : 교환되는 데이터의 추상적인 (abstract) 기술 operation: 서비스가 제공하는 action 에 대한 추상적인 기술 port type : 하나 이상의 endpoint 가 지원하는 operation 의 추상적인 모음 binding: 특정 port type 에 대한 구체적 (concrete) 인 프로토콜 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: WSDL 1.1

WSDL 1.1

Page 2: WSDL 1.1

2

WSDL 1.1 네트웍 상의 서비스를 기술하는 XML 문서 구성

types: 데이터 타입에 대한 정의 message : 교환되는 데이터의 추상적인 (abstract) 기술 operation: 서비스가 제공하는 action 에 대한 추상적인 기술 port type : 하나 이상의 endpoint 가 지원하는 operation 의

추상적인 모음 binding: 특정 port type 에 대한 구체적 (concrete) 인 프로토콜 port : binding 과 network 상의 주소를 가지는 endpoint service : 네트웍 enpoint (port) 의 collection

Page 3: WSDL 1.1

3

WSDL Component<service>: Service 정의 (port, binding)

<port>: endpoint 정의

<binding>: service 를 호출 하는 방법 정의 ( 프로토콜 , style)

<portType>: interface 정의(operation, input, output)

<operation>: method 정의

<message>: message 정의

<types>: datatypes 정의 (XML schema)

Page 4: WSDL 1.1

4

WSDL 을 읽는 방법

<service> <port name="StockQuotePort“

binding="impl:StockQuoteBinding"><service>

<service> <port name="StockQuotePort“

binding="impl:StockQuoteBinding"><service>

<binding name="StockQuoteSoapBinding“ type="impl:StockQuotePortType"><binding name="StockQuoteSoapBinding“ type="impl:StockQuotePortType">

<portType name="StockQuotePortType">

<input message="impl:GetLastTradePriceInput" />  

<output message="impl:GetLastTradePriceOutput" />

<portType name="StockQuotePortType">

<input message="impl:GetLastTradePriceInput" />  

<output message="impl:GetLastTradePriceOutput" />

<message name="GetLastTradePriceInput"> 

<part name="body" element="xsd1:TradePriceRequest" />  

</message>

<message name="GetLastTradePriceInput"> 

<part name="body" element="xsd1:TradePriceRequest" />  

</message>

<types>

<element name="TradePriceRequest">

<complexType> <all> 

<element name="tickerSymbol" type="string" />

<types>

<element name="TradePriceRequest">

<complexType> <all> 

<element name="tickerSymbol" type="string" />

12

3

4

5

Page 5: WSDL 1.1

5

WSDL 의 예 <binding name="QueryIPSoap" type="s0:QueryIPSoap"> s0:QueryIpSoap

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

extensibility element <operation name="Query"> <soap:operation soapAction="http://ws.cdyne.com/Query" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding>

<service name="QueryIP"> <port name="QueryIPSoap" binding="s0:QueryIPSoap"> s0:QueryIPSoap <binding> <soap:address location="http://ws.cdyne.com/whoisforip/queryip.asmx" /> extensibility

element </port> </service></defintion>

Page 6: WSDL 1.1

6

WSDL 의 예<?xml version="1.0" encoding="utf-8"?><definitions xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/” xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://ws.cdyne.com/" xmlns:soapenc=“http://schemas.xmlsoap.org/soap/encoding/” targetNamespace="http://ws.cdyne.com/" xmlns=“http://schemas.xmlsoap.org/wsdl/”/>

<types> … </types>

<message name="QuerySoapIn"> <part name="parameters" element="s0:Query" /> s0:Query 는 <types> 에 정의되어

있음 </message> <message name="QuerySoapOut"> <part name="parameters" element="s0:QueryResponse" /> </message>

<portType name="QueryIPSoap"> <operation name="Query"> <input message="s0:QuerySoapIn" /> QuerySoapIn <message> <output message="s0:QuerySoapOut" /> QuerySoapOut <message> </operation> </portType>

Page 7: WSDL 1.1

7

WSDL 의 예 데이터 타입을 정의하는데 사용하는 type system 에는 제한이 없으나 현재로서는 XML Schema 를

일반적으로 사용함

<types> <s:schema elementFormDefault="qualified" targetNamespace="http://ws.cdyne.com/">

extensibility elelemt <s:element name="Query"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="Address" type="s0:Address" /> <s:element minOccurs="0" maxOccurs="1" name="LicenseKey" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:complexType name="Address">

<s:sequence> <s:element minOccurs="1" maxOccurs="1" name="IPaddress" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="HostName" type="s:string"/> </s:sequence> </s:complexType>

<s:element name="QueryResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="QueryResult" type="s:string" /> </s:sequence> </s:complexType> </s:element> </s:schema> </types>

Page 8: WSDL 1.1

8

WSDL 도식화

created by XMLSpy

Page 9: WSDL 1.1

9

WSDL 을 읽는 방법

<service> <port name="StockQuotePort“

binding="impl:StockQuoteBinding"><service>

<service> <port name="StockQuotePort“

binding="impl:StockQuoteBinding"><service>

<binding name="StockQuoteSoapBinding“ type="impl:StockQuotePortType"><binding name="StockQuoteSoapBinding“ type="impl:StockQuotePortType">

<portType name="StockQuotePortType">

<input message="impl:GetLastTradePriceInput" />  

<output message="impl:GetLastTradePriceOutput" />

<portType name="StockQuotePortType">

<input message="impl:GetLastTradePriceInput" />  

<output message="impl:GetLastTradePriceOutput" />

<message name="GetLastTradePriceInput"> 

<part name="body" element="xsd1:TradePriceRequest" />  

</message>

<message name="GetLastTradePriceInput"> 

<part name="body" element="xsd1:TradePriceRequest" />  

</message>

<types>

<element name="TradePriceRequest">

<complexType> <all> 

<element name="tickerSymbol" type="string" />

<types>

<element name="TradePriceRequest">

<complexType> <all> 

<element name="tickerSymbol" type="string" />

12

3

4

5

Page 10: WSDL 1.1

10

WSDL SOAP Binding SOAP 메시지 구성 방법을 기술

<wsdl:binding> 및 <wsdl:port> 아래에 element 아래에 extensibility element 로 기술

soap:binding soap:operation soap:body soap:header soap:headerfault soap:fault soap:address

Page 11: WSDL 1.1

11

soap:binding soap:binding

<binding …><soap:binding transport=“uri” style=“rpc|document”/></binding>

style : document

SOAP Body 구성시 <message> 의 part 들을 그대로 SOAP Body 에 사용 rpc

SOAP 의 RPC convention 에 따라서 SOAP Body 구성 transport: SOAP 메시지 전송에 사용될 transport

HTTP : http://schemas.soap.org/soap/http

Page 12: WSDL 1.1

12

soap:operation soap:operation

<binding> <operation…> <soap:operation soapAction=“uri” style=“rpc|document”/> </operation></binding>

soapAction : SOAPAction 의 값을 지정 style: rpc/document. <soap:binding> 에서 지정한 style 을

override 할 수 있으나 일반적으로 이런 방식으로는 사용하지 않음

Page 13: WSDL 1.1

13

soap:body soap:body

<binding…> <operation…> <input> <soap:body parts=“nmtokens”? use=“literal|encoded”? encodingStyle=“uri-list”? namespace=“uri”?/> </input> </operation></binding>

parts: SOAP Body 에 사용될 part 들 . 생략하면 해당 메시지의 모든 파트가 사용됨

use : literal : <types> 에 지정된 XML Schema 의 instance 를 SOAP 메시지

구성에 사용함 encoded : <types> 에 지정된 XML Schema 에 encodingStyle 에

지정된 encoding rule 을 적용하여 SOAP 메시지에 담을 concrete 한 메시지를 구성

encodingStyle: encoding 에 사용될 encoding 방식을 기술

namespace: encoding 시 types 에 명시적으로 정의되지 않은 content 에 적용되는

namespace

Page 14: WSDL 1.1

14

Document/RPC, Literal/SOAP Encoding ? 네 가지 조합

RPC/Encoded RPC/Literal DOC/Encoded DOC/Literal

XML 문서의 validation Encoded 방식

WSDL 의 <Types> 에 정의된 XML Schema 를 따르지 않는 XML 문서가 발생될 수 있음

encoded 방식의 XML 문서를 받아서 검증 (validate) 할 수 없음 Literal 방식

WSDL 의 <Types> 에 정의된 XML Schema 로 검증가능한 XML 문서를 주고 받음 현재까지 , 그리고 향후에는…

현재까지 RPC/Encoded 방식과 DOC/Literal 방식이 가장 많이 사용됨 WS-I Basic Profile 에서는 interoperable 한 SOAP 메시징에서는 SOAP

Encoding 방식을 사용하는 것을 금지하고 있음 향후 웹서비스에서는 RPC/Literal 과 , DOC/Literal 방식만이 interaoperable

할것 임 그러나 과거 호환성을 위해서 RPC/encoded 방식도 지원될 것 . SOAP 규격은 Document 중심으로 가고 있음

Page 15: WSDL 1.1

15

WSDL binding (I)

<message name=“Request”><part name=“x” type=“xs:int”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType>

<message name=“Request”><part name=“x” type=“xs:int”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType>

<types><schema>

<element name=“xElement” type=“xs:int”/>

</schema></types>

<message name=“Request”><part name=“x” element=“xElement”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType>

RPC/Literal Document

RPC/Encoding

Page 16: WSDL 1.1

16

WSDL binding (II)

<soap:envelope><soap:body>

<method><x xsi:type=“xs:int”>5</x>

</method></soap:body>

</soap:envelope>

<soap:envelope><soap:body>

<method><x>5</x>

</method></soap:body>

</soap:envelope>

<soap:envelope><soap:body>

<xElement>5</xElement></soap:body>

</soap:envelope>

RPC/ Literal Document

RPC/Encoding

Page 17: WSDL 1.1

17

WSDL binding (III)

<types><schema>

<element name=“method”><complexType>

<sequence> <element name=“x” type=“xs:int”/></sequence>

</complexType></element>

</schema></types>

<message name=“Request”><part name=“parameters” element=“method”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType

<soap:envelope><soap:body>

<method><x>5</x>

</method>></soap:body>

</soap:envelope>

Document/literal wrapped

Page 18: WSDL 1.1

Top-down Web service development

Page 19: WSDL 1.1

19

웹서비스개발 모델 웹서비스 top-down 모델

웹 브라우저로 서비스의 URL 에 접근 가능한 서비스 interface 를 만든다 . Ex) http://localhost:8080/axis/services/WidgetPrice

WSDL 파일을 만들다 . 주고 받을 Type 에 대한 정의를 한다 . -

> simple type 정의 complex type 정의하고 simple type

을 포함한다 . 웹서비스 툴을 이용 server skeleton

JavaBeans components 를 생성한다 . skeleton JavaBeans 에 비즈니스

로직을 작성한다 . 웹서비스 툴을 이용 client stub

JavaBeans components 를 생성한다 . stub JavaBeans components 에

비즈니스 로직을 작성한다 . Test

< 그림 : top-down design>

Page 20: WSDL 1.1

20

SOAP/XML types Java types

xsd:base64Binary byte[]

xsd:boolean boolean

xsd:byte byte

xsd:dateTime java.util.Calendar

xsd:decimal java.math.BigDecimal

xsd:double double

xsd:float float

xsd:hexBinary byte[]

xsd:int int

xsd:integer java.math.BigInteger

xsd:long long

xsd:QName javax.xml.namespace.QName

xsd:short short

xsd:string java.lang.String

Basic Data Type

Page 21: WSDL 1.1

21

Custom Data Type[Order WSDL Type]<wsdl:types><schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Example6"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="ArrayOf_xsd_string"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/> </restriction> </complexContent> </complexType> <complexType name="ArrayOf_xsd_int"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:int[]"/> </restriction> </complexContent> </complexType> <complexType name="Order"> <sequence> <element name="customerName" nillable="true" type="xsd:string"/> <element name="itemCodes" nillable="true" type="impl:ArrayOf_xsd_string"/> <element name="quantities" nillable="true" type="impl:ArrayOf_xsd_int"/> <element name="shippingAddress" nillable="true" type="xsd:string"/> </sequence> </complexType></schema></wsdl:types>

[Order Java class]

public class Order { private String customerName; private String itemCodes[]; private int quantities[]; private String shippingAddress;}

Page 22: WSDL 1.1

22

Axis 의 WSDL 지원 WSDL 문서 제공

웹서비스 툴인 Axis 에서 서비스를 전개할 때 , 웹서비스 사용자들는 웹 브라우 저로 서비스의 URL 에 접근 가능

URL 의 끝에 "http://localhost:8080/axis/services/WidgetPrice?WSDL” 를 덧붙이는 것에 의해 WSDL 제공

WSDL 을 이용해 proxies(stub) 와 skeletons 제공 AXIS WSDL -> Java tool : org.apache.axis.wsdl.WSDL2Java WSDL -> Java class 매칭

type -> java class(Adress, Book, Order), in/out parameter portType -> interface class binding -> stub, skeletons class service -> client service interface, client service implementation

Client / Server 공통 WidgetPrice.java (java.rmi.Remote usages), deploy.wsdd, undeploy.wsdd

Client proxies WidgetPriceService.java (client side service interface) WidgetPriceServiceLocator.java (client side service implementation) WidgetPriceSoapBindingStub.java (Client side stub)

Server skeletons WidgetPriceSoapBindingSkeleton.java (Server side skeleton) WidgetPriceSoapBindingImpl.java (fill out the implementation)

Page 23: WSDL 1.1

23

Axis 의 WSDL 지원 Java2WSDL 도구 제공

java2wsdl 은 자바 클래스들에서 WSDL 을 추출 제공 ex) 아래와 같은 service Interface 작성후 java2wsdl 실행 후

WSDL 얻음public interface WidgetPrice { public void setWidgetPrice(String widgetName, String price); public String getWidgetPrice(String widgetName); public String processOrder(Order order);}

Page 24: WSDL 1.1

WSDL2.0

Page 25: WSDL 1.1

25

definitions 네임스페이스 변경

<definitions name="StockQuote"targetNamespace="http://example.com/stockquote/definitions"xmlns:tns="http://example.com/stockquote/definitions"xmlns:xsd1="http://example.com/stockquote/schemas"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns="http://schemas.xmlsoap.org/wsdl/">

-->

<definitions name="StockQuote"targetNamespace="http://example.com/stockquote/definitions"xmlns:tns="http://example.com/stockquote/definitions"xmlns:xsd1="http://example.com/stockquote/schemas"xmlns:soap="http://www.w3.org/2003/11/wsdl/soap12"xmlns="http://www.w3.org/2003/11/wsdl">

WSDL2.0 에서의 변화 W3C 의 Web Services Description Working Group 은 WSDL 2.0

working drafts on 26 March 2004 definitions 네임스페이스 변경

Page 26: WSDL 1.1

26

message element(construct) 의 삭제<message name="GetLastTradePriceInput"> <part name="body" element="xsd1:TradePriceRequest"/></message><message name="GetLastTradePriceOutput"> <part name="body" element="xsd1:TradePrice"/></message>

-->

<types> <schema targetNamespace="http://example.com/stockquote/definitions"> <element name="GetLastTradePriceInput" type="xsd1:TradePriceRequest"/> <element name="GetLastTradePriceOutput" type="xsd1:TradePrice"/> </schema></types>

Page 27: WSDL 1.1

27

PortTypes 과 Ports 변경<portType name="StockQuotePortType">

->

<interface name="StockQuoteInterface">

<port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/></port>

->

<endpoint name="StockQuoteEndPoint" binding="tns:StockQuoteSoapBinding"> <wsoap:address location="http://example.com/stockquote"/></endpoint>