Вы находитесь на странице: 1из 23

Simple Object Access Protocol

Web Services Description Language

alfady@scs-net.org alnashed@scs-net.org

***"#$
%& ' (
)" !
........................................................................ INTRODUCTION

.. SIMPLE OBJECT ACCESS PROTOCOL

...................................................................................... Why SOAP SOAP

............................................................. SOAP Building Blocks SOAP

........................................................................................ Syntax Rules

........................ Optional SOAP Header Eelement ! SOAP


................................................................................... Actor Element Actor
....................................................... mustUnderstand Element mustUnderstand
........................................................... encodingStyle Element encodingStyle

.................................................... The SOAP Body Element SOAP "

........................................................................... The HTTP Protocol HTTP

......................................... SOAP HTTP Binding HTTP # SOAP

WEB SERVICES DESCRIPTION LANGUAGE WSDL $ % & '


.........................................................................................................

................................................................................. What is WSDL WSDL ' ()

.................................................................................. WSDL Document WSDL


............................................................ WSDL Document Structure WSDL
...................................................................................... WSDL Ports WSDL
.............................................................................. WSDL Messages WSDL
.................................................................................... WSDL Types WSDL
................................................................................. WSDL Binding WSDL

............................................................................................ WSDL Ports WSDL *

2
...................................................................................... WSDL Binding WSDL

....................................................................................... WSDL WSDL

3
Introduction
! " #$ % &
, - & . /0 ' ()* + $ +( !
B2C Business to consumer % $12 ) 1 )
31 4 5! 1 6 12 7 % $12 1 $ 5 4 5! 2 1/ #$
$1 9 :/% 3 " : " 1 4 % %$ 3 )/ 8%& $ %/ 7
1 *4 = 5 ; <
3 ) + /* 1 4 >*

Simple Object Access Protocol &1 $


< 1& ) % 6 XML ? @ >1/ & $
* ) % % A 4 ' $ 9 HTTP $
6 . B Platform Independent @" 4C %/ 9 B42
W3C C 3/ ! 9 BD ) >1/ ? '

E Why SOAP SOAP 4


# ? % RPC + & =9 4 % ' 4 +/
RPC B6 ) % 4 F HTTP $ %$ B DCOM , CORBA
9 # <& ? $ ) % G 1$" ) %
< % H
3 7 B HTTP $ < 9 % A I G
J 9 ( ) , SOAP $ : " *4 ! B ' I & $% 4/
>1/ & % A % K 9 HTTP $ < ' 2
1 ) @ B 1 @" C

SOAP Building Blocks SOAP $ : .1


& % I XML ? 1 %/ + / 9 SOAP $
SOAP $ XML ? 1 ? & D 1 Envelope ? 1@ / •

4
1& D D D / •
), :/ ' 1& D D Body % $ / •
) & :# # : G 1& % K D D ; / •

Syntax Rules $ / !
XML 4 " % ) SOAP •
Enveloped 1@ % $ % ) SOAP •
Encoded +( % $ % ) SOAP •
XML ) & 1& D '% ) SOAP •

Skeleton SOAP Message

<?xml version="1.0"?>

<soap:Envelope

xmlns:soap="http://www.w3.org/2001/12/soap-envelope"

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>

...

...

</soap:Header>

<soap:Body>

...

...

<soap:Fault>

5
...

...

</soap:Fault>

</soap:Body>

</soap:Envelope>

&) D 9 SOAP F G & 9 SOAP ? 1@ / %*


$3 & 7 XML ? 1 ( D 9 M 4A $ SOAP XML L ? 1
6 11 xmlns:soap < %/ 6 4 SOAP
xmlns:soap="http://www.w3.org/2001/12/soap-envelope+
NameSpace ) 3 7 SOAP ? 1@ 3 ; ? 1@ !% $ J2
>@1 ; < ?1 NameSpace 4 83

Optional SOAP Header ' SOAP $ /


Eelement
42 SOAP %/ + 1& D D / 9 /
PAYMENT 5 1 / %/ 1& G + 2" %G # <
NTransN & >1/ Header 3 D >1/G # %*
BN N NmustUnderstandN
I ' nameSpace 7 A # SOAP ? &
9 J9 Nhttp://www.w3.org/2001/12/soap-envelopeN
actor •
mustUnderstand •
encodingStyle •
' 1/ 4 ? $ 1

6
Actor Element Actor
+& 3 ! < + / >* % soap %*
2 9 J9 2 %8 6

Syntax

soap:actor="URI"

Example

<soap:Header>

<m:Trans

xmlns:m="http://www.w3schools.com/transaction/"

soap:actor="http://www.w3schools.com/appml/">

234

</m:Trans>

</soap:Header>

mustUnderstand Element mustUnderstand


' 4 2) & % >1/ ) * J9 4
D 4D )* 9 M> &
D 2 $ * •
D )* 2 $ * •

7
Syntax

soap:mustUnderstand="0|1"

Example

soap:Header>

<m:Trans

xmlns:m="http://www.w3schools.com/transaction/"

soap:mustUnderstand="1">

234

</m:Trans>

</soap:Header>

encodingStyle Element encodingStyle


J9 ?1 4 & 4 encodingStyle
$ & & 6 & H 9 SOAP /D 5 2C !
OI 3

Syntax

soap:encodingStyle="URI"

Example

<?xml version="1.0"?>

<soap:Envelope

xmlns:soap="http://www.w3.org/2001/12/soap-envelope"

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

8
...

Message information goes here

...

</soap:Envelope>

1& soap D D 9 Body soap 4 ) /

The SOAP Body Element SOAP $ 4) /

<soap:Body>

<m:GetPrice xmlns:m="http://www.w3schools.com/prices">

<m:Item>Apples</m:Item>

</m:GetPrice>

</soap:Body>

B soap /% F 9 Getprice < %/ BP & 1 < #


& 1 Item < %/ 4# % Prices & G '
1 $ ) ' % $ P

<soap:Body>

<m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">

<m:Price>1.90</m:Price>

</m:GetPriceResponse>

</soap:Body>

9
The HTTP Protocol HTTP $
%G 6 TCP/IP $ < & ' $ % HTTP $ &
& ## 2 TCP/IP $ B & $ 9
4 5 Q TCP $ 4 HTTP $ ISO ? %
$" >1/ 4 > * HTTP 1 % ( 7 B TTP

POST /item HTTP/1.1

Host: 189.123.345.239

Content-Type: text/plain

Content-Length: 200

% ( > * HTTP ) ' 1 = & 4 R /

200 OK

Content-Type: text/plain

Content-Length: 200

, 1/ P ) 9 B 9 a status code & 4 < #


+& % $ J9 S & ? 1 42 4 *4 % 7 '
$" % !
400 Bad Request

Content-Length: 0

SOAP HTTP Binding HTTP $ 5 SOAP $


1 2 HTTP ) 1/ 1 1 / %/ + / Soap 4& T 2 %*
. XML 5 < Soap % 5I
HTTP + XML = SOAP

10
%/ % 9 Soap 1 % 1/
HTTP POST request
HTTP GET request

Content-Type and Content-Length 9 HTTP % )

Content-Length: bytes

Example

POST /item HTTP/1.1

Content-Type: application/soap+xml; charset=utf-8

Content-Length: 250

4 Content-Length < %/ 4 Content-Type < %/ 7


soap 4 ) /
4/ #
The SOAP request
POST /InStock HTTP/1.1
Host: www.stock.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.stock.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

11
A SOAP response
HTTP/1.1 200 OK
Content-Type: application/soap; charset=utf-8
Content-Length: nnn
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.stock.org/stock">
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
</m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>

12
Web Services Description Language WSDL ? @
WSDL (Web Services Description Language ? @ %*
2 ' ? XML ( >1/ @ %/ + /
2& &
$G 4 9U!
@1 J 9 9 %/ 7 WSDL @ 9 •
WSDL @1 $ : ()G %/ 7 WSDL •
WSDL port interface D WSDL @1 2) 7 WSDL •
D WSDL @1 2) %/ 7 WSDL •
WSDL binding interface
< # : ) $ WSDL @1 1 $ / - & WSDL @ / ! •
W3C

What is WSDL WSDL @ 9


+ / WSDL (Web Services Description Language ? @ %*
& 2 ' ? XML ( >1/ @ %/
XML @1 G V >1/ &1 % $ % 6 1/ WSDL @ ! 2&
Schema Namespaces / I
29 ( +/ 2
? 4 •
XML L $ •
XML %/ + / •
& & . 4 W3C !% # •
$ %/ + / 9 ? & S @ 9 WSDL @ %* *
5! A# 4 %;$ ? 94 7 XML @1
J9 1/ <
> G !7 W3C % I WSDL @1 >1/ ? &
Ariba, IBM and $" !% W3C + $ $ @1 J 9 % WSDL 1.1

13
7 M ) XML ' $ >1/ & ? Microsoft
U 1 5 )1 21&) W3C K 4 $ %/ + / 9 W3C $ %
' W3C $ " & 7 K $ " +/ !% 9 2
K < 2 K !% $ !% $ % + I &
WSDL 1.2 Q Draft & SW > 2/ " $ 2I/
( W3C !%

WSDL Document WSDL


XML $ $ 9 WSDL % 6$ $
? & ? & % / ) >1/ D

WSDL Document Structure WSDL


& 4 WSDL ? &

? Element &
L 4 1& ? & 4 <portType>
9
L messages ? & 4 <message>
!%
data types L & L ? & 4 <types>
!%
L ' ' $ ? & 4 <binding>
!%

14
>1/ WSDL

<definitions>

<types>

definition of types........

</types>

<message>

definition of a message....

</message>

<portType>

definition of a port.......

</portType>

<binding>

definition of a binding....

</binding>

</definitions>

extension & / # X / I D % WSDL %$


% I & + & & +/ 5 ) / A # elements
/ !+ A % WSDL @1 1 $ / >1/ HA , 6 $ B WSDL
WSDL

WSDL Ports WSDL


94 B WSDL % I & 49 % ZportTypeY &
2 %$ B 9 %$ 1& B ? & &

15
) @ % I + ? $ # $ ZportTypeY & & % %$
1

WSDL Messages WSDL


!% messages ? & ZmessageY & 4
:() % ? ; % %$ 1& & /? & 4 7
1 ) @ % I 5 $ : () 3 " 6 $ B #$

WSDL Types WSDL


!% data types & ? & ZtypesY & 4
/ !F WSDL @ 4 X G @1 $ 5 ) %
& ? & XML Schema

WSDL Binding WSDL .2.2


!% ' ' $ ? & ZbindingY & 4
$ ) % 6 4 @ ? & 4 $

#
WSDL % :() .I # 1

<part name="value" type="xs:string"/>

</message>

<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>

16
? & $ 1 4 $ NglossaryTermsN ? & portType & 4 < #
2 NgetTermN 1 & ? & 4 $ B NgetTermN 4 3 I 1/
/ ? & NgetTermResponseN 4 ' T NgetTermRequestN 4 '
) @ 5 2 & $ : () message
3 $ % I 5 NgetTermN $ $ glossaryTerms & 1
NgetTermRequestN 9 T NgetTermRequestN 9

WSDL Ports WSDL


!% 2 / 4 1& 2) ? WSDL 4
9 WSDL @ / #$ 9 ZportTypeY & %8 $ $B
9( ) *%$ 1& ? & & 94 7
) @ + ? $ 32 " 6 $ ? &
1 ) @ % I 5 3 I 1 / $ 3 " %$ $ $ 1
6 5 %$ / " #$G H request-response ) [ 1 H &
& G ' WSDL @ ? &

? & H
L 1 &1 %$ J) One-way
) & % %$
1 &1 %$ ) [ 1 Request-response
) & ?
L * L 1 &1 %$ ) \: ) Solicit-response
) ' C ' 4 4# % 1
? L * 1 &1 %$ &"* Notification
) ' C ' 4 %

17
One-Way J) H % 1/
J) 1 / >1/ # 1

<message name="newTermValues">

<part name="term" type="xs:string"/>

<part name="value" type="xs:string"/>

</message>

<portType name="glossaryTerms">

<operation name="setTerm">

<input name="newTerm" message="newTermValues"/>

</operation>

</portType >

NsetTermN >/ J) 1/ ? & NglossaryTermsN 4 < #


NnewTermValuesN 4 F 1+ ) 1 8 1& J9 .
1& J2 T D ? & 4 ' NvalueN NtermN 9 ;D

Request-Response ) ] 1 1/
1& % H 9 %/ # 1
) \ 1 H % 1/ ? & NglossaryTermsN 4 # 9 7 )
1& J9 1 .1 1 ) 8 1& J9 4 B NgetTermN 9
T & ? NtermN 2 NgetTermRequestN >/
NvalueN >/ 5 NgetTermResponseN

18
<message name="getTermRequest">

<part name="term" type="xs:string"/>

</message>

<message name="getTermResponse">

<part name="value" type="xs:string"/>

</message>

<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>

WSDL Binding WSDL


!% ' ' $ ? & ZBindingY & 4 $ $
$ ) % 6 4 @ ? & 4 $
) \ 1 1/ D D # ;
<message name="getTermRequest">

<part name="term" type="xs:string"/>

</message>

<message name="getTermResponse">

<part name="value" type="xs:string"/>

</message>

<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>

19
</operation>
</portType>

<binding type="glossaryTerms" name="b1">

<soap:binding style="document"

transport="http://schemas.xmlsoap.org/soap/http" />

<operation>

<soap:operation

soapAction="http://example.com/getTerm"/>

<input>

<soap:body use="literal"/>

</input>

<output>

<soap:body use="literal"/>

</output>

</operation>

</binding>

? & type H B name 4 ' 9% binding & 61


J D 4' 4 6$ & 1/ 4 name 4 '
6 1 NglossaryTermsN & 1& 1 " type H
transport B style 4 I % soap:binding &
NdocumentN $" % NrpcN $" % style 4 % $ % %$
? & 4 HTTP Bdocument + G 4 1
& 4 HTTP 9 4 $ SOAP 5 4 $

20
SOAP 7 ? & 4 1/ $ ) % 2I & 1/ $ ? & operation
NliteralN T ( $ I % ) <

WSDL WSDL / !
@ ! 3 4 $ WSDL Syntax Q 1$ / 1
W3C %/ + Draft
<wsdl:definitions name="nmtoken"? targetNamespace="uri">

<import namespace="uri" location="uri"/> *

<wsdl:documentation .... /> ?

<wsdl:types> ?

<wsdl:documentation .... /> ?

<xsd:schema .... /> *

</wsdl:types>

<wsdl:message name="ncname"> *

<wsdl:documentation .... /> ?

<part name="ncname" element="qname"? type="qname"?/> *

</wsdl:message>

<wsdl:portType name="ncname"> *

<wsdl:documentation .... /> ?

<wsdl:operation name="ncname"> *

<wsdl:documentation .... /> ?

<wsdl:input message="qname"> ?

21
<wsdl:documentation .... /> ?

</wsdl:input>

<wsdl:output message="qname"> ?

<wsdl:documentation .... /> ?

</wsdl:output>

<wsdl:fault name="ncname" message="qname"> *

<wsdl:documentation .... /> ?

</wsdl:fault>

</wsdl:operation>

</wsdl:portType>

<wsdl:serviceType name="ncname"> *

<wsdl:portType name="qname"/> +

</wsdl:serviceType>

<wsdl:binding name="ncname" type="qname"> *

<wsdl:documentation .... /> ?

<-- binding details --> *

<wsdl:operation name="ncname"> *

<wsdl:documentation .... /> ?

<-- binding details --> *

<wsdl:input> ?

<wsdl:documentation .... /> ?

22
<-- binding details -->

</wsdl:input>

<wsdl:output> ?

<wsdl:documentation .... /> ?

<-- binding details --> *

</wsdl:output>

<wsdl:fault name="ncname"> *

<wsdl:documentation .... /> ?

<-- binding details --> *

</wsdl:fault>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="ncname" serviceType="qname"> *

<wsdl:documentation .... /> ?

<wsdl:port name="ncname" binding="qname"> *

<wsdl:documentation .... /> ?

<-- address details -->

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

23

Вам также может понравиться