CSPP51038 - PowerPoint PPT Presentation

1 / 81
About This Presentation
Title:

CSPP51038

Description:

WSDL Components a WSDL document uses the following elements in the definition of network services: Types a container for data type definitions using some type ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 82
Provided by: Office2004513
Category:
Tags: cspp51038 | wsdl

less

Transcript and Presenter's Notes

Title: CSPP51038


1
CSPP51038
  • WSDL in depth

2
Advanced Schema features(required for
understanding wsdl)
3
ltxsanygt
  • Can use ltxsany namespacegt in schema to
    specify extensibility elements
  • any element can go here from the specific
    namespaces
  • Common technique to allow flexibility in instance
    documents without forcing change to schema
  • We will see the wsdl files rely heavily on this
  • Strong implications for validation

4
ltxsanygt
ltxsanygt id
xsID
maxOccurs ( xsnonNegativeInteger
unbounded ) 1
minOccurs xsnonNegativeInteger
1 namespace
( (any other ) list of (xsanyURI

targetNamespace local) ) )
any processContents
(skip lax strict) strict

any any element from any namespace other
any element from any namespace other than the
target targetNamespace any element from the
target skip do not attempt validation of these
elements (by looking for schema) lax attempt
validation but dont complain if you cant find
schema strict attempt validation and error if
you cant find schema
5
Validation
  • How is validation done for these ltxsanygt
    elements?
  • Very important up to processing tool to try to
    find schema
  • You can use xsischemaLocation within specific
    element
  • You can leave it up to the tool to figure out.
    Most will
  • Look up URI and see if anything is there
  • Have copy of standard schema (soap-enc, etc.)
  • Look it up in a registry

6
WeatherReport.xsd
lt?xml version"1.0" encoding"UTF-8"?gt ltxsschema
xmlnsxs"http//www.w3.org/2001/XMLSchema"
xmlnswthr"http//www.ccis.com/ace104/weather"
elementFormDefault"qualified"
targetNamespace"http//www.cccis.com/ace104/weath
er"gt ltxselement name"weatherReport"gt
ltxscomplexTypegt ltxssequencegt
ltxselement name"temperature"
type"xsfloat"/gt ltxselement
name"windSpeed" type"xsinteger"/gt
ltxselement name"humidity" type"xsfloat"/gt
ltxsany namespace"http//www.ccc
is.com/ace104/weather/cities"
processContents"strict"/gt
lt/xssequencegt lt/xscomplexTypegt
lt/xselementgt lt/xsschemagt
7
Cities.xsd
ltxsschema xmlnsxs"http//www.w3.org/2001/XMLSch
ema" targetNamespace"http//www.cccis.com/ace
104/weather/cities" elementFormDefault"quali
fied"gt ltxselement name"city"gt
ltxscomplexTypegt ltxssequencegt
ltxselement name"name"
type"xsstring"/gt ltxselement
name"state"gt
ltxssimpleTypegt
ltxsrestriction base"xsstring"gt
ltxsenumeration value"FL"/gt
ltxsenumeration value"AL"/gt
ltxsenumeration
value"MD"/gt
lt/xsrestrictiongt
lt/xssimpleTypegt lt/xselementgt
ltxselement name"zipcode"
type"xsstring/gt lt/xssequencegt
lt/xscomplexTypegt lt/xselementgt lt/xssche
magt
8
Weather.xml
lt?xml version"1.0" encoding"UTF-8"?gt ltwthrweath
erReport xmlnswthr"http//www.cccis.com/ace104/w
eather" xmlnsxsi"http//www.w3.org/2001/XMLS
chema-instance" xsischemaLocation"http//www
.cccis.com/ace104/weather file/Users/siegela
/Desktop/xs_any_examples.xsd"gt
ltwthrtemperaturegt32lt/wthrtemperaturegt
ltwthrwindSpeedgt23lt/wthrwindSpeedgt
ltwthrhumiditygt100lt/wthrhumiditygt ltccity
xmlnsc"http//www.cccis.com/ace104/weather/citie
s" xsischemaLocation"http//www.cccis.co
m/ace104/weather/cities
file/Users/siegela/Desktop/cities.xsd"gt
ltcnamegtMiamilt/cnamegt ltcstategtFLlt/cstat
egt ltczipcodegt33169lt/czipcodegt
lt/ccitygt lt/wthrweatherReportgt
Most explicit way to tell validator where schema
is located is to Use schemaLocation
9
XMLschema-instance
  • The XML schema standard also defines several
    attributes for direct use in any XML documents.
  • These attributes are in a different namespace
  • http//www.w3.org/2001/XMLSchema-instance
  • We have used one of these extensively already --
    xsischemaLocation
  • Note that the standard prefix is xsi but in
    practice, any prefix can be used. All schema
    processors have appropriate attribute
    declarations for these attributes built in

10
xsischemaLocation
  • Recall that the xsischemaLocation and
    xsinoNamespaceSchemaLocation attributes can be
    used in a document to provide hints as to the
    physical location of schema documents which may
    be used for assessment
  • Processing tool may choose to override these
    suggestions to avoid breaking instance documents
    if a resource moves

11
ltxsitypegt attribute
  • The simple or complex type definition used in
    validation of an element is usually determined by
    reference to the appropriate schema components.
  • An element information item in an instance may,
    however, explicitly assert its type using the
    attribute xsitype.
  • The value of this attribute is a Qname
  • As we will see this is used in SOAP documents

12
Why xsitype?
  • Why would we want the instance document to
    specify the type?
  • Not really necessary simply for validation, since
    we could use xsunion to allow an element
    definition to hold several types simultaneously
  • Becomes important when we need the tool that
    reads the instance-document to know what type
    occurred in the instance doc!

13
  • ltmethodCallgt
  • ltmethodNamegt
  • ltgetStateNamegt
  • lt/methodNamegt
  • ltparamsgt
  • ltparamgt
  • ltvaluegt
  • lti4gt
  • 41
  • lt/i4gt
  • lt/valuegt
  • lt/paramgt
  • lt/paramsgt
  • lt/methodCallgt
  • ltmethodCallgt
  • ltmethodNamegt
  • ltgetStateNamegt
  • lt/methodNamegt
  • ltparamsgt
  • ltparamgt
  • ltvalue xsitypexsintgt
  • 41
  • lt/valuegt
  • lt/paramgt
  • lt/paramsgt
  • lt/methodCallgt

Example rpc-type mechanism showing flexibility of
defining type withing xml instance
14
What about schema
  • There are a few types of relationships that can
    exist between schema type definition and the
    xsitype
  • Corresponding schema contains different type
    definition and xsitype.. overrides it
  • Corresponding schema has general type and
    xsitype.. restricts it
  • For complext types, corresponding schema has base
    or abstract type and xsitype.. subclasses it
    (see next slide)

15
Abstract types and xsitype
  • As mentioned, another use of xsitype is to
    specify a concrete instance of an abstract
    complex type within an instance document
  • It can also be used to specify a concrete
    subclass of a non-abstract type, though this is
    often not as useful since it does not prohibit
    the base type from appearing in the instance
    document

16
bookBase
ltxscomplexType name"bookbase" abstract"true"gt
ltxssequencegt ltxselement
ref"isbn"/gt ltxselement ref"title"
minOccurs"0" maxOccurs"unbounded"/gt
ltxselement ref"author" minOccurs"0"
maxOccurs"unbounded"/gt ltxselement
ref"character" minOccurs"0" maxOccurs"unbounded
"/gt lt/xssequencegt ltxsattribute
ref"id"/gt ltxsattribute ref"title"/gt
ltxsattribute ref"available"/gt
lt/xscomplexTypegt
This derived type accepts only title attributes
(note that element is implied eliminated by not
appearing in the sequence, whereas attribute is
implied to still exist).
17
bookTitleAttribute
ltxscomplexType name"bookTitleAttribute"gt
ltxscomplexContentgt ltxsrestriction
base"bookbase"gt ltxssequencegt
ltxselement ref"isbn"/gt
ltxselement ref"author"
minOccurs"0" maxOccurs"unbounded"/gt
ltxselement ref"character" minOccurs"0"
maxOccurs"unbounded"/gt
lt/xssequencegt lt/xsrestrictiongt
lt/xscomplexContentgt lt/xscomplexTypegt
The base type accepts book elements with optional
titles defined as attributes or elements.
18
bookTitleElements
ltxscomplexType name"bookTitleElements"gt
ltxscomplexContentgt ltxsrestriction
base"bookbase"gt ltxssequencegt
ltxselement ref"isbn"/gt
ltxselement ref"title" minOccurs"1"
maxOccurs"unbounded"/gt
ltxselement ref"author" minOccurs"0"
maxOccurs"unbounded"/gt
lt/xssequencegt ltxsattribute
ref"title" use"prohibited"/gt
lt/xsrestrictiongt lt/xscomplexContentgt
lt/xscomplexTypegt
This type does not allow titles as attributes but
only as one or more elements
19
Corresponding XML
ltbook id12345 availabletrue
xsitypebookTitleElementsgt ltisbngt
9294854839 lt/isbngt lttitle langengt
Apology for Raymond de Sabonde lt/titlegt
lttitle langfrgt Apologie par Raymond de
Sabonde lt/titlegt lt/bookgt
this is required if type is abstract
Note if bookBase is not abstract then a
bookBase type will validate also
20
Another example but using extension rather than
restriction
21
?xml version"1.0" encoding"UTF-8"?gt ltxsschema
xmlnsxs"http//www.w3.org/2001/XMLSchema"gt
ltxselement name"class"gt
ltxscomplexTypegt ltxssequencegt
ltxselement name"title"gt
ltxscomplexTypegt
ltxssimpleContentgt
ltxsextension base"xsstring"gt
ltxsattribute name"courseID"
type"xsstring"/gt
lt/xsextensiongt
lt/xssimpleContentgt
lt/xscomplexTypegt lt/xselementgt
ltxselement name"students"
type"student" minOccurs"2" maxOccurs"200"/gt
ltxselement name"location"
type"xsstring"/gt lt/xssequencegt
lt/xscomplexTypegt lt/xselementgt
Here student type will be declared as abstract
and several subtypes will be defined within the
same schema
22
Student base type
ltxscomplexType name"student" abstract"true"gt
ltxssequencegt ltxselement
name"lastName" type"xsstring"/gt
ltxselement name"firstName" type"xsstring"/gt
ltxselement name"social"
type"xsNMTOKEN"/gt lt/xssequencegt
lt/xscomplexTypegt
23
ltxscomplexType name"gradStudent"gt
ltxscomplexContentgt ltxsextension
base"student"gt ltxssequencegt
ltxselement name"funded"
type"xsboolean"/gt
ltxselement name"gpa" type"xsfloat"/gt
ltxselement name"advisor"
type"xsstring"/gt
lt/xssequencegt lt/xsextensiongt
lt/xscomplexContentgt lt/xscomplexTypegt
Says that gradStudent is a sequence that has
everything in student sequence plus three
additional elements funded, gpa, and advisor
24
ltxscomplexType name"undergradStudent"gt
ltxscomplexContentgt ltxsextension
base"student"gt ltxssequencegt
ltxselement name"gpa"
type"xsfloat"/gt ltxselement
name"major" type"xsstring"/gt
ltxselement name"class" type"xsint"/gt
lt/xssequencegt
lt/xsextensiongt lt/xscomplexContentgt
lt/xscomplexTypegt
Says that undergradStudent is a sequence that has
everything in student sequence plus three
additional elements gpa, major, and class
25
lt?xml version"1.0" encoding"UTF-8"?gt ltclass
xmlnsxsi"http//www.w3.org/2001/XMLSchema-instan
ce" xsinoNamespaceSchemaLocation"file/Users/si
egela/Desktop/class.xsd"gt lttitlegttitle0lt/title
gt ltstudents xsitype"gradStudent"gt
ltlastNamegtlastName0lt/lastNamegt
ltfirstNamegtfirstName0lt/firstNamegt
ltsocialgtsocial0lt/socialgt
ltfundedgttruelt/fundedgt ltgpagt3.2lt/gpagt
ltadvisorgtSmithlt/advisorgt lt/studentsgt
ltstudents xsitype"undergradStudent"gt
ltlastNamegtlastName1lt/lastNamegt
ltfirstNamegtfirstName1lt/firstNamegt
ltsocialgtsocial1lt/socialgt ltgpagt3.5lt/gpagt
ltmajorgtPhilosophylt/majorgt
ltclassgt2010lt/classgt lt/studentsgt
ltlocationgt"room 201"lt/locationgt lt/classgt
Sample XML instance document showing how required
xsitype attribute selects subclass
26
A little more SOAP
27
SOAP Reminder
  • Recall that there are three parts to SOAP
  • A generic message envelope
  • This is generally considered a nice thing
  • A suggested set of encoding rules (known as
    Section 5 or SOAP encoding)
  • This is more frequently discredited these days
  • A standard for represent remote procedure calls
  • This is somewhat discredited (at best it is
    harmless)

28
SOAP Schema, Envelope element
ltxsschema xmlnsxs"http//www.w3.org/2001/XMLSc
hema" xmlnstns"http//schemas.xmlsoap
.org/soap/envelope/"
targetNamespace"http//schemas.xmlsoap.org/soap/e
nvelope/" gt lt!-- Envelope, header and
body --gt ltxselement name"Envelope"
type"tnsEnvelope" /gt ltxscomplexType
name"Envelope" gt ltxssequencegt
ltxselement ref"tnsHeader" minOccurs"0" /gt
ltxselement ref"tnsBody" minOccurs"1" /gt
ltxsany namespace"other" minOccurs"0"
maxOccurs"unbounded" processContents"lax"
/gt lt/xssequencegt ltxsanyAttribute
namespace"other" processContents"lax" /gt
lt/xscomplexTypegt lt/xsschemagt
29
SOAP Schema, Header element
ltxselement name"Header" type"tnsHeader"
/gt ltxscomplexType name"Header" gt
ltxssequencegt ltxsany namespace"other"
minOccurs"0" maxOccurs"unbounded"
processContents"lax" /gt lt/xssequencegt
ltxsanyAttribute namespace"other"
processContents"lax" /gt lt/xscomplexTypegt
30
SOAP Schema, Body element
ltxselement name"Body" type"tnsBody" /gt
ltxscomplexType name"Body" gt ltxssequencegt
ltxsany namespace"any" minOccurs"0"
maxOccurs"unbounded processContents"lax" /gt
lt/xssequencegt ltxsanyAttribute
namespace"any" processContents"lax" gt
ltxsannotationgt ltxsdocumentationgt Prose
in the spec does not specify that attributes are
allowed on the Body element
lt/xsdocumentationgt lt/xsannotationgt lt/xsanyA
ttributegt lt/xscomplexTypegt
31
lt!-- Global Attributes. The following attributes
are intended to be usable via qualified
attribute names on any complex type referencing
them. --gt ltxsattribute name"mustUnderstand"
gt ltxssimpleTypegt ltxsrestriction
base'xsboolean'gt ltxspattern value'01'
/gt lt/xsrestrictiongt lt/xssimpleTypegt
lt/xsattributegt ltxsattribute name"actor"
type"xsanyURI" /gt ltxssimpleType
name"encodingStyle" gt ltxsannotationgt
ltxsdocumentationgt 'encodingStyle' indicates
any canonicalization conventions followed
in the contents of the containing element.
For example, the value
'http//schemas.xmlsoap.org/soap/encoding/
indicates the pattern described in SOAP
specification lt/xsdocumentationgt lt/xsannotat
iongt ltxslist itemType"xsanyURI" /gt
lt/xssimpleTypegt ltxsattribute
name"encodingStyle" type"tnsencodingStyle" /gt
ltxsattributeGroup name"encodingStyle" gt
ltxsattribute ref"tnsencodingStyle" /gt
lt/xsattributeGroupgt
32
Fault element
ltxselement name"Fault" type"tnsFault" /gt
ltxscomplexType name"Fault" final"extension" gt
ltxsannotationgt ltxsdocumentationgt
Fault reporting structure lt/xsdocumentationgt
lt/xsannotationgt ltxssequencegt
ltxselement name"faultcode" type"xsQName" /gt
ltxselement name"faultstring"
type"xsstring" /gt ltxselement
name"faultactor" type"xsanyURI" minOccurs"0"
/gt ltxselement name"detail"
type"tnsdetail" minOccurs"0" /gt
lt/xssequencegt lt/xscomplexTypegt
33
SOAP Schema, detail type
ltxscomplexType name"detail"gt ltxssequencegt
ltxsany namespace"any" minOccurs"0"
maxOccurs"unbounded" processContents"lax" /gt
lt/xssequencegt ltxsanyAttribute
namespace"any"
processContents"lax" /gt lt/xscomplexTypegt
34
SOAP Encoding
  • Recall that in general a SOAP message needs to be
    able to describe the data that it is carrying to
    the receiver
  • Two ways to do this
  • Refer to a schema from within the SOAP message
    and use regular xs types (literal)
  • Using soap encoding (or some other encoding
    standard) directly within the XML (encoded)
  • Soap-enc relies on xsitype embedded in XML, as
    we just saw!
  • Additional rules for arrays, object graphs, etc.

35
Soap-enc with simple types
  • Simple types are represented using standards xs
    types as
  • ltenv Envelope gt
  • ltenvBodygt
  • ltidentifier xsitypexsdstring gt
  • asdkfj3 339039393
  • lt/identifiergt
  • ltdate xsitypexsddate gt29 October
    2002lt/dategt

36
Literal
  • The literal way to do this does not include a
    type in the XML but rather validates against a
    schema
  • ltpurchaseOrder xmlnshttp//www.cccis.com/po/schem
    a
  • xmlnsxsihttp//www.w3.org.2001/XMLSchema-in
    stance
  • xsischemaLocationhttp//www.cccis.com/po/sc
    hema
  • po.xsd
  • gt
  • ltidentifiergt87 kdjfkl2393894udfk lt/identifiergt
  • lt/purchaseOrdergt

37
Compound Types
  • Soap-enc defines struct and array types that are
    used in SOAP documents
  • Struct is used for aggregate types whose
    components have (possibly) different names. It
    does not carry any special syntax (as well see)
  • array is used when all components have the same
    name
  • The soap-enc schema is not intended to be used by
    itself, but rather embedded within the SOAP
    schema using the ltany namespacegt as we saw
    earlier (with lax processing).

38
ltbillingAddressgt ltnamegtAndrew Kleinlt/namegt
ltstreetgt 901 NW 200 st.lt/streetgt
ltcitygtMiamilt/citygt ltstategtFLlt/stategt
ltzipgt33169lt/zipgt lt/billingAddressgt
ltenvEnvelope xmlnsenvhttp//schemas.xmlsoap.or
g/soap/envelope/
xmlnsxsdhttp//www.w3.org/2001/XMLSchema
xmlnsxsihttp//www.w3.org/2
001/XMLSchema-instance
xmlnsenchttp//schemas.xmlsoap.org/soap/encodin
g/ xmlnsns0http//www.
cccis.com/xml envencodingStyleht
tp//schemas.xmlsoap.org/soap/encoding/gt
ltenvBodygt ltns0billingAdressgt ltname
xsitypexsdstringgtAndrew Kleinlt/namegt
ltstreet xsitypexsdstringgt901 NW 200
st.lt/streetgt ltcity
xsitypexsdstringgt33169lt/zipgt
lt/ns0billingAddressgt
Names matter but order doesnt
39
ltemailAddressesgt ltemailgtsiegela_at_uchicago.edult/em
ailgt ltemailgt rbaker_at_cccis.comlt/emailgt lt/emailAdd
ressesgt
ltenvEnvelope xmlnsenvhttp//schemas.xmlsoap.or
g/soap/envelope/
xmlnsxsdhttp//www.w3.org/2001/XMLSchema
xmlnsxsihttp//www.w3.org/2
001/XMLSchema-instance
xmlnsenchttp//schemas.xmlsoap.org/soap/encodin
g/ xmlnsns0http//www.
cccis.com/xml envencodingStyleht
tp//schemas.xmlsoap.org/soap/encoding/gt
ltenvBodygt ltns0emailAddresses
xsitypeencArray ecnarrayTypexsdString2
gt ltemail xsitypexsdstringgtsiegela_at_uchic
ago.edult/emailgt ltemail xsitypexsdstring
gtrbaker_at_cccis.comlt/emailgt lt/ns0emailAddresses
gt
If all types are the same these are optional
40
2d arrays, etc.
  • Soap encoding also allows multidimensional arrays
    using references, etc.
  • ltns0ArrayOfPaymentDetail idID1
    xsitypeencArray
  • encarrayTypens0Paymentdetail2
    gt
  • ltitem hrefID2/gt
  • ltitem hrefID3/gt
  • lt/ns0ArrayOfPaymentDetailgt

41
Web Services
42
Web Services
  • Here is a simple starting definition
  • A Web Service is a software component that is
    described via WSDL and is capable of being
    accessed via standard network protocols such as
    but not limited to SOAP over HTTP - Oasis
    Consortium

43
WSDL
  • WSDL (Web Services Definitons Language) is the
    Interface Definition Language (IDL) of web
    services.
  • To truly understand web services it is necessary
    to have a very deep understanding of the WSDL
    standard (and its associated problems)
  • Relying on high level tools for rpc is not
    adequate!

44
WSDL
  • WSDL is an XML format for describing network
    services as a set of endpoints operating on
    messages containing either document-oriented or
    procedure-oriented information.
  • The operations and messages are described
    abstractly, and then bound to a concrete network
    protocol and message formats to define an
    endpoint.
  • Related concrete endpoints are combined into
    abstract endpoints (services).
  • WSDL is extensible to allow description of
    endpoints and their messages regardless of what
    message formats or network protocols are used to
    communicate, however, the only bindings described
    in the SOAP standard describe how to use WSDL in
    conjunction with SOAP 1.1, HTTP GET/POST, and
    MIME.

45
WSDL Components
  • a WSDL document uses the following elements in
    the definition of network services
  • Types
  • a container for data type definitions using some
    type system (such as XSD).
  • Message
  • an abstract, typed definition of the data being
    communicated.
  • Operation
  • an abstract description of an action supported by
    the service.
  • Port Type
  • an abstract set of operations supported by one or
    more endpoints.
  • Binding
  • a concrete protocol and data format specification
    for a particular port type.
  • Port
  • a single endpoint defined as a combination of a
    binding and a network address.
  • Service
  • a collection of related endpoints.

46
?xml version"1.0"?gt ltdefinitions
name"StockQuote" targetNamespace"http//example
.com/stockquote.wsdl"
xmlnstns"http//example.com/stockquote.wsdl"
xmlnsxsd1"http//example.com/stockquote.x
sd" xmlnssoap"http//schemas.xmlsoap.o
rg/wsdl/soap/" xmlns"http//schemas.xml
soap.org/wsdl/"gt lttypesgt ltschema
targetNamespace"http//example.com/stockquote.xsd
" xmlns"http//www.w3.org/2000/10/X
MLSchema"gt ltelement name"TradePriceReq
uest"gt ltcomplexTypegt
ltallgt ltelement
name"tickerSymbol" type"string"/gt
lt/allgt lt/complexTypegt
lt/elementgt ltelement
name"TradePrice"gt ltcomplexTypegt
ltallgt
ltelement name"price" type"float"/gt
lt/allgt lt/complexTypegt
lt/elementgt lt/schemagt lt/typesgt
Sample WSDL showing types element
47
Sample wsdl showing message and portType elements
ltmessage name"GetLastTradePriceInput"gt
ltpart name"body" element"xsd1TradePriceRequest"
/gt lt/messagegt ltmessage name"GetLastTradePriceO
utput"gt ltpart name"body"
element"xsd1TradePrice"/gt lt/messagegt
ltportType name"StockQuotePortType"gt
ltoperation name"GetLastTradePrice"gt
ltinput message"tnsGetLastTradePriceInput"/gt
ltoutput message"tnsGetLastTradePriceOutput
"/gt lt/operationgt lt/portTypegt
48
ltbinding name"StockQuoteSoapBinding"
type"tnsStockQuotePortType"gt
ltsoapbinding style"document"
transport"http//schemas.xmlsoap.org/soap/http
"/gt ltoperation name"GetLastTradePrice"gt
ltsoapoperation
soapAction"http//example.com/GetLastTradePrice"/
gt ltinputgt ltsoapbody
use"literal"/gt lt/inputgt
ltoutputgt ltsoapbody
use"literal"/gt lt/outputgt
lt/operationgt lt/bindinggt
49
ltservice name"StockQuoteService"gt
ltdocumentationgtMy first servicelt/documentationgt
ltport name"StockQuotePort"
binding"tnsStockQuoteBinding"gt
ltsoapaddress
location"http//example.com/stockquote"/gt
lt/portgt lt/servicegt lt/definitionsgt
50
Port types
A port type is a named set of abstract operations
and the abstract messages involved. ltwsdldefini
tions .... gt ltwsdlportType name"nmtoken"gt
ltwsdloperation name"nmtoken" ....
/gt lt/wsdlportTypegt lt/wsdldefinitionsgt
51
Messaging Modes
WSDL has four transmission primitives that an
endpoint can support ?One-way. The endpoint
receives a message. ?Request-response. The
endpoint receives a message, and sends a
correlated message. ?Solicit-response. The
endpoint sends a message, and receives a
correlated message. ?Notification. The endpoint
sends a message.
52
One-way operations
The grammar for a one-way operation
is ltwsdldefinitions .... gt ltwsdlportType
.... gt ltwsdloperation
name"nmtoken"gt ltwsdlinput
name"nmtoken"? message"qname"/gt
lt/wsdloperationgt lt/wsdlportType
gt lt/wsdldefinitionsgt The input element
specifies the abstract message format for the
one-way operation.
53
Request-response
The grammar for a request-response operation
is ltwsdldefinitions .... gt ltwsdlportType
.... gt ltwsdloperation name"nmtoken"
parameterOrder"nmtokens"gt ltwsdlinput
name"nmtoken"? message"qname"/gt
ltwsdloutput name"nmtoken"? message"qname"/gt
ltwsdlfault name"nmtoken"
message"qname"/gt lt/wsdloperationgt
lt/wsdlportType gt lt/wsdldefinitionsgt Note that
a request-response operation is an abstract
notion a particular binding must be consulted to
determine how the messages are actually sent
within a single communication (such as a
HTTP request/response), or as two independent
communications (such as two HTTP requests).
54
Solicit-response
The grammar for a solicit-response operation
is ltwsdldefinitions .... gt ltwsdlportType
.... gt ltwsdloperation name"nmtoken"
parameterOrder"nmtokens"gt
ltwsdloutput name"nmtoken"? message"qname"/gt
ltwsdlinput name"nmtoken"?
message"qname"/gt ltwsdlfault
name"nmtoken" message"qname"/gt
lt/wsdloperationgt lt/wsdlportType
gt lt/wsdldefinitionsgt The output and input
elements specify the abstract message format
for the solicited request and response,
respectively. The optional fault elements specify
the abstract message format for any error
messages that may be output as the result of the
operation (beyond those specific to the
protocol).
55
Notification
The grammar for a notification operation
is ltwsdldefinitions .... gt ltwsdlportType
.... gt ltwsdloperation name"nmtoken"gt
ltwsdloutput name"nmtoken"?
message"qname"/gt lt/wsdloperationgt
lt/wsdlportType gt lt/wsdldefinitionsgt The output
element specifies the abstract message format for
the notification operation.
56
  • A binding defines message format and protocol
    details for operations
  • and messages defined by a particular portType.
  • There may be any number of bindings for a given
    portType.
  • The grammar for a binding is as follows

ltwsdldefinitions .... gt ltwsdlbinding
name"nmtoken" type"qname"gt lt--
extensibility element (1) --gt
ltwsdloperation name"nmtoken"gt lt--
extensibility element (2) --gt
ltwsdlinput name"nmtoken"? gt ?
lt-- extensibility element (3) --gt
lt/wsdlinputgt ltwsdloutput
name"nmtoken"? gt ? lt--
extensibility element (4) --gt
lt/wsdloutputgt ltwsdlfault
name"nmtoken"gt lt--
extensibility element (5) --gt
lt/wsdlfaultgt lt/wsdloperationgt
lt/wsdlbindinggt lt/wsdldefinitionsgt
Specified by ltxsany namespaceother/gt
57
  • The name attribute provides a unique name among
    all bindings defined
  • within in the enclosing WSDL document.
  • A binding references the portType that it binds
    using the type
  • attribute. This QName value follows the linking
    rules defined by WSDL
  • Binding extensibility elements are used to
    specify the concrete
  • grammar for the input (3), output (4), and fault
    messages
  • (5). Per-operation binding information (2) as
    well as per-binding
  • information (1) may also be specified.
  • An operation element within a binding specifies
    binding information
  • for the operation with the same name within the
    binding's
  • portType. Since operation names are not required
    to be unique (for
  • example, in the case of overloading of method
    names), the name
  • attribute in the operation binding element might
    not be enough to
  • uniquely identify an operation. In that case, the
    correct operation
  • should be identified by providing the name
    attributes of the
  • corresponding wsdlinput and wsdloutput
    elements.

58
A port defines an individual endpoint by
specifying a single address for a
binding. ltwsdldefinitions .... gt
ltwsdlservice .... gt ltwsdlport
name"nmtoken" binding"qname"gt lt--
extensibility element (1) --gt
lt/wsdlportgt lt/wsdlservicegt lt/wsdldefinition
sgt
59
More about binding element
The name attribute provides a unique name among
all ports defined within in the enclosing WSDL
document. The binding attribute (of type QName)
refers to the binding using the linking rules
defined by WSDL (see Section 2.1.2). Binding
extensibility elements (1) are used to specify
the address information for the port. A port
MUST NOT specify more than one address. A port
MUST NOT specify any binding information other
than address information.
60
Service element
A service groups a set of related ports
together ltwsdldefinitions .... gt
ltwsdlservice name"nmtoken"gt
ltwsdlport .... /gt lt/wsdlservicegt lt/wsdldef
initionsgt The name attribute provides a unique
name among all services defined within in the
enclosing WSDL document.
61
  • Ports within a service have the following
    relationship
  • None of the ports communicate with each other
    (e.g. the output of one
  • port is not the input of another). If a service
    has several ports
  • that share a port type, but employ different
    bindings or addresses,
  • the ports are alternatives. Each port provides
    semantically equivalent
  • behavior (within the transport and message format
    limitations imposed
  • by each binding). This allows a consumer of a
    WSDL document to choose
  • particular port(s) to communicate with based on
    some criteria
  • (protocol, distance, etc.).
  • By examining its ports, we can determine a
    service's port types.
  • This allows a consumer of a WSDL document to
  • determine if it wishes to communicate to a
    particular service based
  • whether or not it supports several port types.
    This is useful if there
  • is some implied relationship between the
    operations of the port types,
  • and that the entire set of port types must be
    present in order to
  • accomplish a particular task.

62
Next Steps
  • We now need to study in detail the binding
    element
  • Before we do this we will solidify what weve
    learned by doing several group exercises based on
    what we know so far

63
Abstract service description
  • SimpleMathService
  • Operation add
  • Input list of numbers
  • Output single number (sum)
  • Operation extrema
  • Input list of numbers
  • Output two numbers (min and max)

64
lt?xml version"1.0" encoding"UTF-8"?gt ltwsdldefin
itions targetNamespace"http//www.example.co
m/webservice" xmlnshttp"http//schemas.xmlso
ap.org/wsdl/http/" xmlnsmime"http//schemas.
xmlsoap.org/wsdl/mime/" xmlnssoap"http//sch
emas.xmlsoap.org/wsdl/soap/"
xmlnssoapenc"http//schemas.xmlsoap.org/soap/enc
oding/" xmlnswsdl"http//schemas.xmlsoap.org
/wsdl/" xmlnsxs"http//www.w3.org/2001/XMLS
chema" xmlnsxsi"http//www.w3.org/2001/XMLSc
hema-instance" xmlnsws"http//www.example.co
m/webservice"gt
  • wsdl root is the definitions element
  • targetNamespace attribute is namesapce that
    global elements
  • of this wsdl are placed. This is important for
    qname references
  • every other namespace is used to refer to
    elements from
  • corresponding schema within certain
    extensibility locations of
  • wsdl file

65
ltwsdltypesgt ltxsschema
targetNamespace"http//www.example.com/webservice
"gt ltxscomplexType name"numberListTyp
e"gt ltxssequencegt
ltxselement name"number" type"xsfloat"/gt
lt/xssequencegt
lt/xscomplexTypegt lt/xsschemagt
lt/wsdltypesgt
Types element is used to define any non-basic
types that are used for the messages defined
subsequently. Recall that it is also ok to
import a schema file rather than inline one Here
I only need one derived type -- to represent a
list of numbers both for extrema and add
services
66
ltwsdlmessage name"mathOpsInput"gt
ltwsdlpart name"numberList" type"wsnumberListTy
pe"/gt lt/wsdlmessagegt ltwsdlmessage
name"addOpOutput"gt ltwsdlpart
name"number" type"xsfloat"/gt
lt/wsdlmessagegt ltwsdlmessage
name"extremaOutput"gt ltwsdlpart
name"min" type"xsfloat"/gt ltwsdlpart
name"max" type"xsfloat"/gt lt/wsdlmessagegt
  • each message represents what can be thought of
    as
  • input and output data for a particular
    operation(s)
  • each data element is specified as a ltwsdl partgt
    and has
  • either a simple or derived datatype
  • parts can be thought of as parameters if we
    think of rpc --
  • but we can think more loosely of
    message-oriented

67
ltwsdlportType name"simpleMath"gt
ltwsdloperation name"add"gt
ltwsdlinput message"wsmathOpsInput"/gt
ltwsdloutput message"wsaddOpOutput"/gt
lt/wsdloperationgt ltwsdloperation
name"extrema"gt ltwsdlinput
message"wsmathOpsInput"/gt
ltwsdloutput message"wsextremaOutput"/gt
lt/wsdloperationgt lt/wsdlportTypegt
  • portType is a collection of functions. In this
    case we only
  • have two and one portType is adequate. In
    general we can
  • make more detailed groupings.
  • for two-way request-response messages, each
    portType has
  • an input and an output message. These messages
    are referred
  • to using the message attribute. They must refer
    to message
  • elements defined in the same wsdl (qnames)

68
ltwsdlbinding name"simpleMathSoapBinding"
type"wssimpleMath"gt ltsoapbinding
style"rpc" transport"http//schemas.xmlsoap.org/
soap/http"/gt ltwsdloperation name"add"gt
ltsoapoperation soapAction"http//peop
le.cs.uchicago.edu/ace104/math"/gt
ltwsdlinputgt ltsoapbody
use"encoded"/gt lt/wsdlinputgt
ltwsdloutputgt ltsoapbody
use"encoded"/gt lt/wsdloutputgt
lt/wsdloperationgt lt!-- similar for extrema
operation --gt lt/wsdlbindinggt
This combination can give a lot of portability
headaches
  • the binding element makes the abstract portType
    definitions
  • concrete. Here we bind the message to SOAP over
    http
  • other details are very important
  • useencoded literal to use soap encoding
    vs datatypes
  • associated with schema
  • stylerpc document represent as method
    name, params
  • vs. use XML instance directly as body.

69
ltwsdlservice name"simpleMathService"gt
ltwsdldocumentationgtSimple Math
Operationslt/wsdldocumentationgt
ltwsdlport name"simpleMath" binding"wssimpleMat
hSoapBinding"gt ltsoapaddress
location"http//people.cs.uchicago.edu/"/gt
lt/wsdlportgt lt/wsdlservicegt
  • Service is a collection of ports with their
    associated bindings
  • It is common to have multiple bindings for the
    same port
  • for example both SOAP (over http) and direct
    http
  • mime, SMTP are other common bindings
  • you can also create your own without changing
    the wsdl
  • however, it probably wont be too useful for
    others

70
WSDL SOAP Analyzer
  • Good idea to use a tool to validate your WSDL and
    check for adherence to WS-I interoperability
    standards.
  • Also, good idea to see sample auto-generated SOAP
    messages for the various combinations of
    settings.
  • These can be quite a mess. document/literal seems
    to be the best bet for portability

71
A one-way example
  • Access a Date Service that returns the Date and
    GMT
  • Input none
  • Output date and time
  • Allow multiple bindings to single port

72
ltwsdlmessage name"dateTimeOutput"gt
ltwsdlpart name"dateTime" type"xsdate"/gt
lt/wsdlmessagegt
ltwsdlportType name"Date"gt
ltwsdloperation name"getDateTime"gt
ltwsdloutput message"wsdateTimeOutput"/gt
lt/wsdloperationgt lt/wsdlportTypegt
73
ltwsdlbinding name"DateSoapBinding"
type"wsDate"gt ltsoapbinding
transport"http//schemas.xmlsoap.org/soap/http"/gt
ltwsdloperation name"getDateTime"gt
ltsoapoperation soapAction"http//www.exam
ple.com/webservice" style"document"/gt
ltwsdloutputgt
ltsoapbody
encodingStyle"http//schemas.xmlsoap.org/soap
/encoding/" use"encoded"/gt
lt/wsdloutputgt lt/wsdloperationgt
lt/wsdlbindinggt
ltwsdlbinding name"DateHttpGet" type"wsDate"gt
lthttpbinding verb"GET"/gt
ltwsdloperation name"getDateTime"gt
lthttpoperation location"/GetBriefings"/gt
ltwsdloutputgt ltmimemimeXml
part"Body"/gt lt/wsdloutputgt
lt/wsdloperationgt lt/wsdlbindinggt
74
Problems with WSDL
  • WSDL not well defined/described
  • The original spec uses definition by example
  • Early WSDL tools highly incompatible
  • Different interpretations
  • e.g. when to use xsdimport when to use
    wsdlimport
  • Not so bad today (if using the major toolkits)

75
More on binding elementrpc vs. document debate
  • One way to think of this is as follows
  • rpc versus document
  • RPC Style
  • String foo(String s, Integer i)
  • Document Style
  • Class foo
  • String s
  • Integer I
  • String foobar(foo)

76
SOAP-enc versus Literal styles
  • Literal just as plain XML
  • ltstuffgthellolt/stuffgt
  • ltnumbers"gt  ltitemgt10lt/itemgt  ltitemgt20lt/itemgt  lt
    itemgt30lt/itemgt  ltitemgt40lt/itemgt  ltitemgt50lt/itemgt
  • lt/numbersgt
  • SOAP-enc
  • ltstuff xsitypexsdstringgthellolt/stuffgt
  • ltnumbers xsitype"SOAP-ENCArray"
    SOAP-ENCarrayType"xsdinteger5"gt  ltitemgt10lt/i
    temgt  ltitemgt20lt/itemgt  ltitemgt30lt/itemgt  ltitemgt4
    0lt/itemgt  ltitemgt50lt/itemgt
  • lt/numbersgt

77
Object graphs
  • Literal
  • ltDistancegt
  • ltp1gt
  • ltxgt10lt/xgt
  • ltygt20lt/ygt
  • lt/p1gt
  • ltp2gt
  • ltxgt10lt/xgt
  • ltygt20lt/ygt
  • lt/p2gt
  • ltDistancegt
  • SOAP Encoding
  • ltDistancegt
  • ltp1 HREF"id1"/gt
  • ltp2 HREF"id1"/gt
  • lt/Distancegt
  • ltPoint id"id1"gt
  • ltxgt10lt/xgt

78
XML Schema
  • Officially any XML Schema construct is valid in
    WSDL
  • In practice
  • e.g. for a long time Java tools were defined by
    JAX-RPC which defined a subset of valid XML
    Schema
  • e.g. in early stages of SRU the following caused
    headaches
  • xsdpositiveInteger, xsdnonNegativeInteger etc.

79
Enter WS-I
  • Web Service Interoperability profile
  • Key components SOAP, WSDL, UDDI
  • Defines a set of rules for interoperable
    WebServices
  • e.g. use SOAP document/literal style
  • Rules for wsdlimport versus xsdimport
  • Still defines any XML Schema as valid etc.
  • Compliant toolsets much better at interoperating
    today

80
import javax.xml.soap. import
javax.xml.namespace.QName import
java.util.Iterator import java.net.URL public
class Request public static void
main(String args) try
SOAPConnectionFactory soapConnectionFactory
SOAPConnectionFactory.newInstance()
SOAPConnection connection
soapConnectionFactory.createConnection()
MessageFactory factory
MessageFactory.newInstance() SOAPMessage
message factory.createMessage()
SOAPHeader header message.getSOAPHeader()
SOAPBody body message.getSOAPBody()
header.detachNode() QName bodyName new
QName("http//wombat.ztrade.com",
"GetLastTradePrice", "m") SOAPBodyElement
bodyElement body.addBodyElement(bodyName
)
81
QName name new QName("symbol")
SOAPElement symbol bodyElement.addChildE
lement(name) symbol.addTextNode("SUNW")
URL endpoint new URL
("http//wombat.ztrade.com/quotes")
SOAPMessage response connection.call(mes
sage, endpoint) connection.close()
SOAPBody soapBody response.getSOAPBody()
Iterator iterator soapBody.getChildEle
ments(bodyName) bodyElement
(SOAPBodyElement)iterator.next() String
lastPrice bodyElement.getValue()
System.out.print("The last price for SUNW is ")
System.out.println(lastPrice) catch
(Exception ex) ex.printStackTrace()
Write a Comment
User Comments (0)
About PowerShow.com