CS/INFO 330: Web Driven Web Applications Web Services Definition: - - PowerPoint PPT Presentation
CS/INFO 330: Web Driven Web Applications Web Services Definition: - - PowerPoint PPT Presentation
CS/INFO 330: Web Driven Web Applications Web Services Definition: Web Services A standardized way of integrating Web- based applications, using XML to tag data SOAP to transport data Simple Object Access Protocol WSDL to
Definition: Web Services
- A standardized way of integrating Web-
based applications, using
- XML to tag data
- SOAP to transport data
- Simple Object Access Protocol
- WSDL to describe available services
- Web Services Description Language
- An Interface Description Language
(IDL)
- UDDI to list available services
- Universal Description, Discovery and
Integration
Goals for B2B Integration
- Service-Oriented Architecture
- Redesign of middleware protocols
- Standardization
Service-Oriented
- Service: procedure, method, or object
with stable published interface
- Functionality always exposed as
services
- Loosely coupled
- Invoked by programs as well as users
Middleware Redesign
- Peer-to-Peer
- No central coordinator
- Between trust domains
- Compatibility with Internet
Web Services Integrating Between Companies
internal infrastructure
supplier customer warehouse
internal infrastructure internal infrastructure internal procurement requests internal functionality made available as a service Web service Web service Web service interactions based on protocols redesigned for peer to peer and B2B settings languages and protocols standardized, eliminating need for many different middleware infrastructures (need only the Web services middleware)
Basic Web Services
- Components:
- communicate (SOAP)
- describe services - IDL (WSDL)
- directory service (UDDI)
Minimalist Infrastructure ...
service provider service requestor
application object (client) application object (service provider) SOAP-based middleware SOAP-based middleware SOAP messages exchanged on top of, HTTP, SMTP, or other transport converts procedure calls to/ from XML messages sent through HTTP or other protocols.
Using WSDL Specification
service provider service requestor
application object (client) application object (service provider) stub skeleton WSDL of service provider WSDL compiler (server side) WSDL compiler (client side) <operation name="orderGoods"> <input message = "OrderMsg"/ > </ operation> SOAP-based middleware SOAP-based middleware SOAP messages
Note all WSDL “processing” happens at development time.
Using UDDI Registry
service descriptions
SOAP-based middleware
UDDI registry service provider service requestor
application object (client) application object (service provider) stub skeleton SOAP-based middleware SOAP-based middleware SOAP messages SOAP messages (to look for services) SOAP messages (to publish service description)
Simple Object Access Protocol
- Specifies:
- message format for one-way comms
- specification for SOAP RPC
- rules for processing SOAP messages
- rules for transport - HTTP and SMTP
A SOAP Message
SOAP envelope SOAP header header block SOAP body body block
Header: info for intermediate nodes Body: actual message
SOAP Message Example
<?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <m:reservation xmlns:m="http://travelcompany.example.org/reservation" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference> <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime> </m:reservation> <n:passenger xmlns:n="http://mycompany.example.com/employees" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <n:name>Åke Jógvan Øyvind</n:name> </n:passenger> </env:Header> <env:Body> <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel"> <p:departure> <p:departing>New York</p:departing> <p:arriving>Los Angeles</p:arriving> <p:departureDate>2001-12-14</p:departureDate> <p:departureTime>late afternoon</p:departureTime> <p:seatPreference>aisle</p:seatPreference> </p:departure> <p:return> <p:departing>Los Angeles</p:departing> <p:arriving>New York</p:arriving> <p:departureDate>2001-12-20</p:departureDate> <p:departureTime>mid-morning</p:departureTime> <p:seatPreference/> </p:return> </p:itinerary> <q:lodging xmlns:q="http://travelcompany.example.org/reservation/hotels"> <q:preference>none</q:preference> </q:lodging> </env:Body> </env:Envelope>
SOAP over HTTP
service provider
SOAP engine service implementation (other tiers) HTTP engine
service requestor
HTTP engine client implementation (other tiers) SOAP engine
Simple Implementation
service requestor
client implementation HTTP engine client stub SOAP engine
invokes the service as a local call invoke SOAP engine to prepare SOAP message packages SOAP into HTTP and passes it to an HTTP client that sends it to the provider
service provider
service implementation HTTP server server stub SOAP router
invokes the local procedure of the service implementation the router parses the message, identifies the appropriate stub, and delivers the parsed message passes the content of the HTTP message to the router
WSDL Specifications
- Abstract part
- signatures,
- perations
- like traditional IDL
- Concrete part
- bindings / services
/ ports
WSDL specification abstract part
types messages
- perations
port types
concrete part
bindings services and ports
Concrete Part
- Interface Bindings
- message encoding and protocol
bindings (e.g., RPC-style operation, communication via SOAP over HTTP)
- Ports
- interface binding + network address
where port type implementation can be accessed
- Services
- logical groupings of ports
Automatic Generation of WSDL
service provider service requestor
application object (client) application object (service provider) stub skeleton WSDL of service provider WSDL compiler (server side) WSDL compiler (client side) SOAP-based middleware SOAP-based middleware SOAP messages WSDL generator
1 2
WSDL Example: GreatH Hotel Reservation Service
<?xml version="1.0" encoding="utf-8" ?> <description xmlns="http://www.w3.org/@@@@/@@/wsdl" targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc" . . . > . . . </description>
WSDL 2.0 empty shell (Example taken from W3C’s WSDL primer)
Message Types
<?xml version="1.0" encoding="utf-8" ?> <description xmlns="http://www.w3.org/@@@@/@@/wsdl" targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc" xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc" . . . > ... <types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://greath.example.com/2004/schemas/resSvc" xmlns="http://greath.example.com/2004/schemas/resSvc"> <xs:element name="checkAvailability" type="tCheckAvailability"/> <xs:complexType name="tCheckAvailability"> <xs:sequence> <xs:element name="checkInDate" type="xs:date"/> <xs:element name="checkOutDate" type="xs:date"/> <xs:element name="roomType" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:element name="checkAvailabilityResponse" type="xs:double"/> <xs:element name="invalidDataError" type="xs:string"/> </xs:schema> </types> . . . </description>
Interface Definition
<?xml version="1.0" encoding="utf-8" ?> <description xmlns="http://www.w3.org/@@@@/@@/wsdl" targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc" xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc" . . . xmlns:wsdlx="http://www.w3.org/@@@@/@@/wsdl-extensions"> . . . <types> ... </types> <interface name = "reservationInterface" > <fault name = "invalidDataFault" element = "ghns:invalidDataError"/> <operation name="opCheckAvailability" pattern="http://www.w3.org/@@@@/@@/wsdl/in-out" style="http://www.w3.org/@@@@/@@/wsdl/style/iri" wsdlx:safe = "true"> <input messageLabel="In" element="ghns:checkAvailability" /> <output messageLabel="Out" element="ghns:checkAvailabilityResponse" /> <outfault ref="tns:invalidDataFault" messageLabel="Out"/> </operation> </interface> . . . </description>
Bindings
Specifies how messages can be exchanged
<?xml version="1.0" encoding="utf-8" ?> <description xmlns="http://www.w3.org/@@@@/@@/wsdl" targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc" xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc" xmlns:wsoap= "http://www.w3.org/@@@@/@@/wsdl/soap" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> . . . <types> . . . </types> <interface name = "reservationInterface" > ... </interface> <binding name="reservationSOAPBinding" interface="tns:reservationInterface" type="http://www.w3.org/@@@@/@@/wsdl/soap" wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP"> <operation ref="tns:opCheckAvailability" wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/> <fault ref="tns:invalidDataFault" wsoap:code="soap:Sender"/> </binding> . . . </description>
Service Definition
Where can the service be accessed
<?xml version="1.0" encoding="utf-8" ?> <description xmlns="http://www.w3.org/@@@@/@@/wsdl" targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc" xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc" xmlns:wsoap= "http://www.w3.org/@@@@/@@/wsdl/soap" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> . . . <types> . . . </types> <interface name = "reservationInterface" > . . . </interface> <binding name="reservationSOAPBinding" interface="tns:reservationInterface" . . . > . . . </binding> <service name="reservationService" interface="tns:reservationInterface"> <endpoint name="reservationEndpoint" binding="tns:reservationSOAPBinding" address ="http://greath.example.com/2004/reservation"/> </service> </description>
Documenting the Service
<?xml version="1.0" encoding="utf-8" ?> <description . . . > <documentation> This document describes the GreatH Web service. Additional application-level requirements for use of this service -- beyond what WSDL 2.0 is able to describe -- are available at http://greath.example.com/2004/reservation-documentation.html </documentation> . . . </description>
The Whole Picture
<?xml version="1.0" encoding="utf-8" ?> <description xmlns="http://www.w3.org/@@@@/@@/wsdl" targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc" xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc" xmlns:wsoap= "http://www.w3.org/@@@@/@@/wsdl/soap" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdlx= "http://www.w3.org/@@@@/@@/wsdl-extensions"> <documentation> This document describes the GreatH Web service. Additional application-level requirements for use of this service -- beyond what WSDL 2.0 is able to describe -- are available at http://greath.example.com/2004/reservation-documentation.html </documentation> <types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://greath.example.com/2004/schemas/resSvc" xmlns="http://greath.example.com/2004/schemas/resSvc"> <xs:element name="checkAvailability" type="tCheckAvailability"/> <xs:complexType name="tCheckAvailability"> <xs:sequence> <xs:element name="checkInDate" type="xs:date"/> <xs:element name="checkOutDate" type="xs:date"/> <xs:element name="roomType" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:element name="checkAvailabilityResponse" type="xs:double"/> <xs:element name="invalidDataError" type="xs:string"/> </xs:schema> </types> <interface name = "reservationInterface" > <fault name = "invalidDataFault" element = "ghns:invalidDataError"/> <operation name="opCheckAvailability" pattern="http://www.w3.org/@@@@/@@/wsdl/in-out" style="http://www.w3.org/@@@@/@@/wsdl/style/iri" wsdlx:safe = "true"> <input messageLabel="In" element="ghns:checkAvailability" /> <output messageLabel="Out" element="ghns:checkAvailabilityResponse" /> <outfault ref="tns:invalidDataFault" messageLabel="Out"/> </operation> </interface> <binding name="reservationSOAPBinding" interface="tns:reservationInterface" type="http://www.w3.org/@@@@/@@/wsdl/soap" wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP"> <fault ref="tns:invalidDataFault" wsoap:code="soap:Sender"/> <operation ref="tns:opCheckAvailability" wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/> </binding> <service name="reservationService" interface="tns:reservationInterface"> <endpoint name="reservationEndpoint" binding="tns:reservationSOAPBinding" address ="http://greath.example.com/2004/reservation"/> </service> </description>