Vous êtes sur la page 1sur 35

WSDL: Web Services Description Language #6#

Outline

What is WSDL? WSDL Specification XML Schema Data Typing

What is WSDL?

WSDL is a specification defining how to describe web services in a common XML grammar. WSDL describes o!r critica" pieces o data# $nter ace in ormation describing a"" p!b"ic"y avai"ab"e !nctions Data type in ormation or a"" message re%!ests and message responses &inding in ormation abo!t the transport protoco" to be !sed 'ddress in ormation or "ocating the specified service
3

What is WSDL?

WSDL represents a contract between the service re%!estor and the service provider &!t in m!ch the same way that a (ava inter ace represents a contract between c"ient code and the act!a" (ava ob)ect. The cr!cia" di erence is that WSDL is p"at orm* and "ang!age* independent and is !sed primari"y +a"tho!gh not e,c"!sive"y- to describe S.'/ services.
4

What is WSDL?

0sing WSDL1 a c"ient can "ocate a web service and invo2e any o its p!b"ic"y avai"ab"e !nctions. With WSDL*aware too"s1 yo! can a"so a!tomate this process1 enab"ing app"ications to easi"y integrate new services with "itt"e or no man!a" code.

WSDL Specification

WSDL is an XML grammar or describing web services. The specification itse" is divided into si, ma)or e"ements# definitions types message portType binding service
6

WSDL Specification

WSDL Specification

Definitions# The definitions e"ement m!st be the root e"ement o a"" WSDL doc!ments. $t defines the namespace o the web service1 dec"ares m!"tip"e namespaces !sed thro!gho!t the remainder o the doc!ment1 and contains a"" the service e"ements described here.

WSDL Specification

types# The types e"ement describes a"" the data types !sed between the c"ient and server. WSDL is not tied e,c"!sive"y to a specific typing system1 b!t it !ses the W34 XML Schema specification as its de a!"t choice. $ the service !ses on"y XML Schema b!i"t*in simp"e types1 s!ch as strings and integers1 the types element is not required. ' !"" disc!ssion o the types e"ement and XML Schema is de erred to the end o the chapter.
9

WSDL Specification

Message# The message e"ement describes a one*way message1 whether it is a sing"e message re%!est or a sing"e message response. $t defines the name o the message and contains 5ero or more message part e"ements1 which can re er to message parameters or message ret!rn va"!es.
10

WSDL Specification

portType# The portType e"ement combines m!"tip"e message e"ements to orm a comp"ete oneway or ro!nd*trip operation. 6or e,amp"e1 a portType can combine one re%!est and one response message into a sing"e re%!est7response operation1 most co mmon"y !sed in S.'/ services. 8ote that a portType can +and re%!ent"y does- define m!"tip"e operations.
11

WSDL Specification

Binding# The binding e"ement describes the concrete specifics o how the service wi"" be imp"emented on the wire. WSDL inc"!des b!i"t*in e,tensions or defining S.'/ service s1 and S.'/*specific in ormation there ore goes here.

12

WSDL Specification

Service# The service e"ement defines the address or invo2ing the specified service. Most common"y1 this inc"!des a 09L or invo2ing the S.'/ service.

13

WSDL Specification

$n addition to the si, ma)or e"ements1 the WSDL specification a"so defines the o""owing !ti"ity e"ements# Documentation# The doc!mentation e"ement is !sed to provide h!man* readab"e doc!mentation and can be inc"!ded inside any other WSDL e"e ment.

14

WSDL Specification

Import# The import e"ement is !sed to import other WSDL doc!ments or XML Schemas. This enab"es more mod!"ar WSDL doc!ments. 6or e,amp"e1 two WSDL doc!ments can import the same basic e"ements and yet inc"!de their own service e"ements to ma2e the same service avai"ab"e at two physica" addresses. 8ote1 however1 that not a"" WSDL too"s s!pport the import !nctiona"ity as o yet.
15

WSDL Example

:,amp"e +word-

16

Definition

The definitions e"ement specifies n!mero!s namespaces that wi"" be !sed thro!gho!t the remainder o the doc!ment#

17

Definition

;wsd"#definitions ,m"ns#http<=http://schemas.xmlsoap.org/ sdl/http/= ,m"ns#soap<=http://schemas.xmlsoap.org/ sdl/soap/= ,m"ns#s<=http:// . !.org/"##$/%M&Schema= ,m"ns#soapenc <=http://schemas.xmlsoap.org/soap/encoding/= ,m"ns#tns<=http://pnote'oo(/Service&a's/Simple)alculator= ,m"ns#tm<=http://microso*t.com/ sdl/mime/textMatching/= ,m"ns#mime<=http://schemas.xmlsoap.org/ sdl/mime/= target8amespace<=http://pnote'oo(/Service&a's/Simple)alcula tor= ,m"ns#wsd"<=http://schemas.xmlsoap.org/ sdl/=>
18

Definition

The !se o namespaces is important or di erentiating e"ements1 and it enab"es the doc!ment to re erence m!"tip"e e,terna" specifications1 inc"!ding WSDL specification S.'/ specification the XML Schema specification. The definitions e"ement a"so specifies a target8amespace attrib!te. The target8amespace is a convention o XML Schema that enab"es the WSDL doc!ment to re er to itse" . 6ina""y1 the definitions e"ement specifies a de a!"t namespace# ,m"ns#wsd"<=http://schemas.xmlsoap.org/ sdl/ = 19

Message

There is ? message e"ements in WSDL. )alsSoapIn )alsSoap+ut )als,rraySoapIn )als,rraySoap+ut

20

Message
;wsd"#message name<=)alsSoapIn=> - ;wsd"#part name<=parameters= e"ement<=tns:)als= 7> ;7wsd"#message> ;wsd"#message name<=)alsSoap+ut=> - ;wsd"#part name<=parameters= e"ement<=tns:)als.esponse= 7> ;7wsd"#message> ;wsd"#message name<=)als,rraySoapIn=> ;wsd"#part name<=parameters= e"ement<=tns:)als,rray= 7> - ;7wsd"#message> ;wsd"#message name<=)als,rraySoap+ut=> - ;wsd"#part name<=parameters= e"ement<=tns:)als,rray.esponse= 7> - ;7wsd"#message>

21

portType
;wsd"#portType name<=Simple)alculatorSoap=> ;wsd"#operation name<=)als=> ;wsd"#inp!t message<=tns:)alsSoapIn= 7> - ;wsd"#o!tp!t message<=tns:)alsSoap+ut= 7> - ;7wsd"#operation> ;wsd"#operation name<=)als,rray=> ;wsd"#inp!t message<=tns:)als,rraySoapIn= 7> ;wsd"#o!tp!t message<=tns:)als,rraySoap+ut= 7> - ;7wsd"#operation> ;7wsd"#portType>

22

portType

WSDL s!pports o!r basic patterns o operation# One-way The service receives a message. The operation there ore has a sing"e inp!t e"ement. Request-response The service receives a message and sends a response. The operation there ore has one inp!t e"ement1 o""owed by one o!tp!t e"ement. Solicit-response Notification
23

portType

Solicit-response The service sends a message and receives a response. The operation there ore has one o!tp!t e"ement1 o""owed by one inp!t e"ement. Notification The service sends a message. The operation there ore has a sing"e o!tp!t e"ement.
24

portType

25

bin ing

The binding e"ement provides specific detai"s on how a portType operation wi"" act!a""y be transmitted over the wire. &indings can be made avai"ab"e via m!"tip"e transports1 inc"!ding @TT/ A:T1 @TT/ /.ST1 or S.'/. $n act1 yo! can speci y m!"tip"e bindings or a sing"e portType.

26

bin ing

;wsd"#binding name<=Simple)alculatorSoap= type<=tns:Simple)alculatorSoap=> - ;soap#binding transport<=http://schemas.xmlsoap.org/ soap/http= sty"e<=document= 7>

27

service

The service e"ement specifies the "ocation o the service. &eca!se this is a S.'/ service1 we !se the soap#address e"e ment1 and speci y the "oca" host address ;soap#address "ocation<=http://localhost/Service&a's/ Simple)alculator.asmx= 7>

28

WSDL !nvocation Tools

yo! co!"d man!a""y create a S.'/ c"ient to invo2e the service. ' better a"ternative is to automatically invo2e the s ervice via a WSDL invocation too".

29

"ML Schema Data Typing

$n order or a S.'/ c"ient to comm!nicate e ective"y with a S.'/ server1 the c"ient and server m!st agree on a data type system. &y de a!"t1 XML B.C does not provide a data type system. $n contrast1 every programming "ang!age provides some basic aci"ity or dec"aring data types1 s!ch as integers1 Doats1 do!b"es1 and strings. WSDL does not aim to create a standard or XML data typing. $n act1 WSDL is specifica""y designed or ma,im!m De,ibi"ity and is there ore not tied e,c"!sive"y to any one data type system.

30

"ML Schema Data Typing


WSDL does de a!"t to the W34 XML Schema specification. The XML Schema specification is a"so c!rrent"y the most wide"y !sed specification or data typing. There is two acts are cr!cia""y important. 6irst1 the XML Schema specification inc"!des a basic type system or encoding most data types. Second1 the XML Schema specification provides a aci"ity or creating new data types. This is important i yo! want to create data types that go beyond what is a"ready defined within the Schema.
31

"ML Schema Data Typing

6or e,amp"e1 a service might ret!rn an array o Doats or a more comp"e, stoc2 %!ote ob)ect containing the high1 "ow1 and vo"!me fig!res or a specific stoc2. Whenever yo!r service goes beyond the simp"e XML Schema data types1 yo! m!st dec"are these new data types within the WSDL types e"ement.

32

#rrays

The WSDL fi"e now inc"!des a types e"ement. $nside this e"ement1 we have defined two new comp"e, types. the XML Schema defines simp"e types and comp"e, types. Simp"e types cannot have e"ement chi"dren or attrib!tes1 comp"e, types can have e"ement chi"dren and attrib!tes. We have dec"ared comp"e, types in o!r WSDL fi"e1 beca!se an array may have m!"tip"e e"ements1 one or each va"!e in the array.
33

$omplex Types

.!r fina" topic is the !se o comp"e, data types. 6or e,amp"e1 consider a home monitoring service that provides a concise !pdate on yo!r home. The data ret!rned co!"d inc"!de m!"tip"e data e"ements1 s!ch as the c!rrent temperat!re1 sec!rity stat!s1 and whether the garage door is open or c"osed. :ncoding this data into WSDL re%!ires additiona" 2now"edge o XML Schemas1 which rein orces the main precept that the more yo! 2now abo!t XML Schemas1 the better yo! wi"" !nderstand comp"e, WSDL fi"es.
34

%uestion & #ns'er

35