Tecnologie per servizi web: WSDL, WSFL - PowerPoint PPT Presentation

About This Presentation
Title:

Tecnologie per servizi web: WSDL, WSFL

Description:

Some Java tools. 3. Roberto Bruni _at_ IMT Lucca. 16 March 2005. Models ... city Milwaukee /city state WI /state zip 53222 /zip /address 13. Roberto Bruni ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 46
Provided by: RB2
Category:

less

Transcript and Presenter's Notes

Title: Tecnologie per servizi web: WSDL, WSFL


1
Models and Languages for Coordination and
Orchestration IMT- Institutions Markets
Technologies - Alti Studi Lucca
WS Technologies II WSDL
Roberto Bruni Dipartimento di Informatica
Università di Pisa
2
Contents
  • WSDL
  • Some Java tools

3
Contents
  • WSDL
  • Some Java tools

4
What is the Story so Far?
  • With UDDI (and SOAP) we know how to find and
    discover new services
  • as if we looked at the yellow pages
  • What can we do with discovered services?
  • should we contact the service provider and ask
    for technical support in programming the right
    SOAP calls?
  • No, this would be a waste of time for both us and
    the provider!
  • Instead, the provider should prepare a
    unambiguous description of the WS to be exposed
  • automatically downloadable, understandable, and
    usable for connecting to the specific WS
  • WSDL fixes the standard for such description

5
Web Services Description Language (WSDL)
  • WSDL is an XML-based language for the description
    of Web Services
  • (and the methods to access them)
  • A WSDL document is just a particular XML document
  • it resides in a file with suffix .wsdl
  • it can be checked for validity against the WSDL
    Schema
  • it describes how to "interface with" and use WS
  • and also the binding protocol to access WS
  • it is a bit complex for human beings
  • but it is unambiguous for a machine

6
The Seven Elements of WSDL
  • Essentially, WSDL documents consist of 7 key
    elements
  • message types (data structures)
  • messages
  • basic units of communication between WS and
    clients
  • typed data to be communicated as a single logical
    transmission
  • operations
  • sequences of messages related to a single action
  • interfaces (called port types in WSDL v1)
  • logical groups of operations representing
    abstract services
  • bindings
  • associations between interfaces and concrete
    protocols / data formats
  • endpoints (called ports in WSDL v1)
  • associations between interface bindings and
    network addresses
  • services (collections of endpoints)

7
A View at WSDL Hierarchical Structure
  • ltdefinitionsgt
  • lttypesgt
  • ltmessagegt
  • ltinterfacegt
  • ltoperationgt
  • ltinputgt
  • ltoutputgt
  • ltbindinggt
  • ltservicegt
  • ltendpointgt

8
Types
  • A type is the most basic WSDL element
  • completely analogous to a Schema document (.xsd)
  • XML Schema are in fact used for defining message
    types
  • a type can correspond to
  • a struct, in C
  • a class with variables but without methods, in
    Java
  • types are necessary to describe the main elements
    and parameters in a method call

9
Examplethe Class Address.java
  • public class Address
  • public String name
  • public String address1
  • public String address2
  • public String city
  • public String state
  • public String zip
  • public class MyClass
  • public void myMethod(Address myAddress)
  • //do something

10
The Schema address.xsd
  • ltxsdschema targetNamespace"/address.xsd"
  • xmlnsxsd"http//www.w3.org/2001/XMLS
    chema"
  • xmlnsaddr"/address.xsd"gt
  • ltxsdelement name"address"
    type"addraddressType" /gt
  • ltxsdcomplexType name"addressType"gt
  • ltxsdsequencegt
  • ltxsdelement name"name"
    type"xsdstring"/gt
  • ltxsdelement name"address1"
    type"xsdstring"/gt
  • ltxsdelement name"address2"
    type"xsdstring"/gt
  • ltxsdelement name"city"
    type"xsdstring"/gt
  • ltxsdelement name"state"
    type"xsdstring"/gt
  • ltxsdelement name"zip"
    type"xsdstring"/gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • lt/xsdschemagt

11
Example address.xsd with Anonymous Types
  • ltxsdschema targetNamespace"/address.xsd"
  • xmlnsxsd"http//www.w3.org/2001/XMLS
    chema"gt
  • ltxsdelement name"address"gt
  • ltxsdcomplexTypegt
  • ltxsdsequencegt
  • ltxsdelement name"name"
    type"xsdstring"/gt
  • ltxsdelement name"address1"
    type"xsdstring"/gt
  • ltxsdelement name"address2"
    type"xsdstring"/gt
  • ltxsdelement name"city"
    type"xsdstring"/gt
  • ltxsdelement name"state"
    type"xsdstring"/gt
  • ltxsdelement name"zip"
    type"xsdstring"/gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • lt/xsdelementgt
  • lt/xsdschemagt

Only if addressType is not used elsewhere
12
Example valid XML document for address.xsd
  • ltaddressgt
  • ltnamegtArthur Fonzarellilt/namegt
  • ltaddress1gt123 W. Wisconsinlt/address1gt
  • ltaddress2gtApt. 4lt/address2gt
  • ltcitygtMilwaukeelt/citygt
  • ltstategtWIlt/stategt
  • ltzipgt53222lt/zipgt
  • lt/addressgt

13
The Type address in WSDL I
  • lt?xml version"1.0"?gt
  • ltwsdldefinitions nameAddressType
  • targetNamespace/addressType.w
    sdl
  • xmlnstns/addressType.wsdl
  • xmlnswsdlhttp//schemas.xmlso
    ap.org/wsdl/gt
  • ltwsdltypesgt
  • ltxsdschema targetNamespace/addressType.w
    sdl
  • xmlnsxsdhttp//www.w3.org/200
    1/XMLSchemagt
  • ltxsdelement name"Address"gt
  • ltxsdcomplexTypegt
  • ltxsdallgt
  • ltxsdelement name"name"
    type"xsdstring"/gt
  • ltxsdelement name"address1"
    type"xsdstring"/gt
  • ltxsdelement name"address2"
    type"xsdstring"/gt
  • ltxsdelement name"city"
    type"xsdstring"/gt
  • ltxsdelement name"state"
    type"xsdstring"/gt

14
The Type address in WSDL II
  • lt!-- (segue)
    --gt
  • ltxsdelement name"zip"
    type"xsdstring"/gt
  • lt/xsdallgt
  • lt/xsdcomplexTypegt
  • lt/xsdelementgt
  • lt/xsdschemagt
  • lt/wsdltypesgt
  • lt/wsdldefinitionsgt

15
Messages
  • On the contrary of types, messages do not have an
    immediate analogy with Java...
  • so we will push it...
  • Imagine a setting where any method can have three
    parameters at most
  • WSDL relies on such assumption
  • (input, output and a third one, fault, for
    exception handling)
  • Thus we must group the parameters of methods
  • this is what messages are for!
  • they have a sub-component part for each parameter

16
Example a Message
  • public void order(Address shipTo, Address
    billTO)
  • //do something

lt?xml version"1.0"?gt ltwsdldefinitions gt
ltwsdltypesgt lt!--
Aggiungiamo un messaggio --gt
ltwsdlmessage name"purchase"gt ltwsdlpart
name"billTo" element"tnsaddress"/gt
ltwsdlpart name"shipTo" element"tnsaddress"/gt
lt/wsdlmessagegt lt/wsdldefinitionsgt
17
Operations
  • wsdloperation is probably the simplest WSDL
    element
  • it correspond to an abstract method in Java
  • but, as said, it has some limitation
  • three parameters at most input, output, fault
  • essentially there are four main different kinds
    of operations
  • one-way
  • (from the client to the service)
  • request/response
  • (request from the client and response back from
    the service)
  • notification
  • (from the service to the client)
  • solicit/response
  • (message from the service and response from the
    client)

18
One-way Operations
  • In general, operations are described by the
    element wsdloperation that can contain one or
    more messages
  • (wsdlinput, wsdloutput, wsdlfault)
  • In one-way operations, only the input element is
    allowed
  • ex.

19
Request/Response Operations
  • Both input and output are defined
  • optionally, an additional fault element
  • ex.

20
Notification Operations
  • Converse of one-way operations
  • only output message is allowed
  • example
  • for notifying the client about the current status
    of the order

21
Solicit/Response Operations
  • Useful when a service needs some information from
    the client
  • example
  • construction of a site with variable bandwidth

22
Interfaces (Port Types)
  • For the moment we have only surveyed standalone
    operations
  • but all the operations make sense only when
    considered within a port type
  • What is a port type?
  • W3C it defines a group of abstract operations
    and their corresponding abstract messages
  • it is equivalent to a Java interface
  • (in WSDL v2, port types are called interfaces)
  • Syntactically, it is defined by an element
    wsdlinterface (wsdlportType in WSDL v1)
  • which contains one or more wsdloperation elements

23
Example Interface
lt?xml version"1.0"?gt ltwsdldefinitions gt
ltwsdltypesgt lt/wsdltypesgt ltwsdlmessage
name"purchase"gt lt/wsdlmessagegt
ltwsdlportType name"submitPurchaseType"gt
ltwsdloperation name"submitPurchase"gt
ltwsdlinput message"tnspurchase" /gt
lt/wsdloperationgt lt/wsdlportTypegt lt/wsdldefin
itionsgt
24
Binding
  • For the moment we have just considered "abstract"
    elements
  • upon receiving a ltwsdlinterfacegt we have all the
    information on how to use it
  • but we cannot create a direct instance
  • To instantiate the interface we must provide the
    information that are necessary to interact with
    it
  • in particular
  • which transport method will the interface use?
  • which communication format are we going to use?
  • The binding defines all details that are needed

25
SOAP Binding on HTTP I
  • lt?xml version"1.0"?gt
  • ltwsdldefinitions name"purchaseExample"
  • targetNamespace"/purchaseExamp
    le.wsdl"
  • xmlnstns"/purchaseExample.wsd
    l"
  • xmlnssoap"http//schemas.xmlso
    ap.org/wsdl/soap"
  • xmlnswsdl"http//schemas.xmlso
    ap.org/wsdl/"gt
  • lt!-- Types --gt
  • ltwsdltypesgt lt/wsdltypesgt
  • lt!-- MESSAGES --gt
  • ltwsdlmessage name"purchaseMessage"gt
    lt/wsdlmessagegt
  • lt! PORT TYPES --gt
  • ltwsdlportType name"purchaseType"gt
  • lt!-- OPERATIONS --gt
  • ltwsdloperation name"purchaseOperation"gt
  • ltwsdlinput messagetnspurchaseMessage
    /gt
  • lt/wsdloperationgt
  • lt/wsdlportTypegt

26
SOAP Binding on HTTP II
  • lt!-- (segue)
    --gt
  • lt!-- BINDING --gt
  • ltwsdlbinding name"purchaseBinding"
  • type"tnspurchaseType"gt
  • ltsoapbinding style"document"
  • transport"http//schemas.xmls
    oap.org/soap/http" /gt
  • ltwsdloperation name"tnspurchaseOperation"
    gt
  • ltwsdlinputgt
  • ltsoapbody use"literal" /gt
  • lt/wsdlinputgt
  • lt/wsdloperationgt
  • lt/wsdlbindinggt
  • lt/wsdldefinitionsgt

HTTP
ex. SOAP, HTTP e SMTP
27
Endpoints (Ports)
  • Once defined the binding to the transport
    protocol we can link the method call to a
    specific IP address
  • the binding defined the communication protocol,
    but not the address of the machine hosting the
    service
  • sych information is given by the element
    wsdlendpoint
  • (called wsdlport in WSDL v1)
  • An endpoint contains
  • a name
  • a binding
  • a network address

28
Example Going Further on Previous Example
  • lt!-- (segue)
    --gt
  • lt!-- BINDING --gt
  • ltwsdlbinding namepurchaseBinding
    typetnspurchaseTypegt
  • ltsoapbinding styledocument
    transport/http /gt
  • ltwsdloperation nametnspurchaseOperation
    gt
  • ltwsdlinputgt ltsoapbody useliteral /gt
    lt/wsdlinputgt
  • lt/wsdloperationgt
  • lt/wsdlbindinggt
  • lt!-- PORTS --gt
  • ltwsdlport namePurchase_ServicePort
  • bindingtnspurchaseBindinggt
  • ltsoapaddress
  • locationhttp//www.fluidimagination.com
    8080/soap/servlet/rpcrouter /gt
  • lt/wsdlportgt
  • lt/wsdldefinitionsgt

29
Services
  • Now we have all ingredients
  • the only thing left is to combine them in a
    single offert
  • analogous to a whole Java class
  • The element wsdlservice is the very first
    element exposed to the interest of users who get
    the .wsdl document
  • it groups all endpoints
  • it allows the server to check if the services
    really supports all the required operations

30
Example for the Last Time
  • lt!-- (segue)
    --gt
  • lt!-- BINDING --gt
  • ltwsdlbinding namepurchaseBinding
    typetnspurchaseTypegt
  • lt/wsdlbindinggt
  • lt!-- SERVICES --gt
  • ltwsdlservice namePurchase_Servicegt
  • ltdocumentationgtblah blah blahlt/documentation
    gt
  • ltwsdlport bindingtnspurchaseBinding
  • namePurchase_ServicePortgt
  • ltsoapaddress location /gt
  • lt/wsdlportgt
  • lt/wsdlservicegt
  • lt/wsdldefinitionsgt

full example
31
Summary
WSDL v1 Java
types classes without methods
messages parameters, return value, errors
port types and operations interfaces
bindings remote communication protocol
services and ports remote classes
32
A WSDL v2 ExampleGreatH Hotel Reservation I
  • Hotel GreatH is located in a remote island
  • for years it has been relying on fax/phone
    reservations
  • now, even though the facilities and prices at
    GreatH are better than what its competitor
    offers, GreatH notices that its competitor is
    getting more customers than GreatH
  • after research, GreatH realizes that this is
    because the competitor offers a Web service that
    permits travel agent reservation systems to
    reserve rooms directly over the Internet

33
A WSDL v2 ExampleGreatH Hotel Reservation II
  • GreatH then wants to build a reservation Web
    service with the following functionalities
  • CheckAvailability
  • the client must specify a check-in date, a
    check-out date, and room type
  • the Web service will provide the room rate if
    such a room is available
  • If any input data is invalid, the service should
    return an error
  • The service will accept a checkAvailability
    message and return a checkAvailabilityResponse or
    invalidDataFault message
  • MakeReservation
  • the client must provide a name, address, and
    credit card information
  • the service will return a confirmation number if
    the reservation is successful
  • the service will return an error message if the
    credit card number or any other data field is
    invalid
  • The service will accept a makeReservation message
    and return a makeReservationResponse or
    invalidCreditCardFault message.

34
A WSDL v2 ExampleGreatH Hotel Reservation III
  • GreatH knows that later the WS will need to
    support transactions and secured transmission
  • but initially we consider the implementation of
    only minimal functionality
  • to simplify the example, we will consider only
    the CheckAvailability operation
  • GreatH.wsdl

35
Using WSDL in a UDDI Registry
  • WSDL complements the UDDI standard by providing a
    uniform way of describing
  • the abstract interface and
  • protocol bindings
  • of arbitrary network services
  • Next, we try to clarify the relationship between
    the two
  • describe how WSDL can be used in UDDI business
    service descriptions
  • WSDL service descriptions can be structured in
    multiple ways
  • if the reusable information is separated from the
    information that is specific to a given service
    instance, the use of WSDL and UDDI together
    becomes particularly simple

36
Authoring UDDI Service Descriptions I
  • The first step is to create the WSDL service
    interface definition
  • Typically, industry groups will define a set of
    service types, and describe them with one or more
    service interface definition WSDL documents
  • The service interface definition will include
    service interfaces and protocol bindings, and
    will be made publicly available
  • The WSDL service interface definitions are then
    registered as a special kind of UDDI tModels,
    called wsdlSpec tModels
  • the overviewDoc field in each new tModel will
    point to the corresponding WSDL document

37
Authoring UDDI Service Descriptions II
  • Next, programmers will build services that
    conform to the industry standard service
    definitions
  • either manually or using appropriate UDDI-aware
    tooling, programmers will retrieve the tModel
    description of the industry standard definition
  • following the overviewDoc link they will obtain
    the corresponding WSDL document
  • WSDL-aware tooling, in turn, can help generate an
    implementation
  • (that supports the standard interfaces and
    bindings)

38
Authoring UDDI Service Descriptions III
  • Finally, the new service must be deployed and
    registered in the UDDI repository
  • either manually or using WSDL/UDDI-aware tooling,
    a UDDI businessService data structure is
  • created,
  • and then registered
  • Typically when using WSDL/UDDI-aware tools, some
    type of deployment descriptor document will be
    generated at that same time

39
Import Element
  • The ltimport location"..."gt element in WSDL
    allows the separation of elements of service
    description into two parts
  • service interface definition (SInt)
  • service implementation definition (SImp)
  • Typically, information common to a certain
    category of business services, such as
  • message formats,
  • portTypes (abstract interfaces),
  • and protocol bindings,
  • are included in the reusable portion (SInt),
  • while information pertaining to a particular
    service endpoint (i.e., port definition) is
    included in the other portion (SImp)
  • Within the context of UDDI,
  • we will be concerned only with the reusable
    portion

40
WSDL and UDDIMonolithic Approach
  • Relevant UDDI Structures
  • businessService
  • bindingTemplate
  • how and where the service is accessed
  • it specifies a network endpoint address (in the
    accessPoint element) and a stack of tModels
    describing the service
  • one tModelInstanceInfo inside the
    tModelInstanceDetails element for each relevant
    tModel
  • tModel, aka service type definition
  • one for each interface/portType
  • classified using uddi-orgtypes taxonomy, as
    being of type "wsdlSpec"
  • must have an overviewDoc whose overviewURL points
    to the WSDL document defining the
    interface/portType

41
Sketch of businessService Structure
  • ltbusinessServicegt
  • (...)
  • ltbindingTemplatesgt
  • ltbindingTemplategt
  • (...)
  • ltaccessPoint urlType"http"gt
  • http//www.etc.com/
  • lt/accessPointgt
  • lttModelnstanceDetailsgt
  • lttModelnstanceInfo tModelKey"..."gt
  • lt/tModelnstanceInfogt
  • (...)
  • lt/tModelnstanceDetailsgt
  • lt/bindingTemplategt
  • (...)
  • lt/bindingTemplatesgt
  • lt/businessServicegt

42
Example tModel
  • lttModel authorizedName"..." operator"..."
    tModelKey"..."gt
  • ltnamegtStockQuote Servicelt/namegt
  • ltdescription xmllang"en"gt
  • WSDL description of a standard stock quote
    service interface
  • lt/descriptiongt
  • ltoverviewDocgt
  • ltdescription xmllang"en"gtWSDL source
    document.lt/descriptiongt
  • ltoverviewURLgthttp//stockquote-definitions/stq
    .wsdllt/overviewURLgt
  • lt/overviewDocgt
  • ltcategoryBaggt
  • ltkeyedReference tModelKey"uuidC1ACF26D-9672-
    4404-9D70-39B756E62AB4"
  • keyName"uddi-orgtypes"
  • keyValue"wsdlSpec"/gt
  • lt/categoryBaggt
  • lt/tModelgt

43
Example businessService
  • ltbusinessService businessKey"..."
    serviceKey"..."gt
  • ltnamegtStockQuoteServicelt/namegt
  • ltdescriptiongt (...) lt/descriptiongt
  • ltbindingTemplatesgt
  • ltbindingTemplategt
  • (...)
  • ltaccessPoint urlType"http"gt
  • http//example.com/stockquote
  • lt/accessPointgt
  • lttModelnstanceDetailsgt
  • lttModelnstanceInfo tModelKey"..."gt
  • lt/tModelnstanceInfogt
  • lttModelnstanceDetailsgt
  • lt/bindingTemplategt
  • lt/bindingTemplatesgt
  • lt/businessServicegt

44
WSDL and UDDIModular Approach
  • The Monolithic approach can be replaced by an
    expanded modelling that encompasses the
  • flexibility
  • and reusability
  • of WSDL
  • fine grain "taxonomy-zation" of WSDL artefacts
  • portType/interface
  • binding
  • service
  • port/endpoint

45
Modular Mapping Overview
Institutions Markets Technologies IMT
Write a Comment
User Comments (0)
About PowerShow.com