Web Services and Their
Protocol Stack
•
The Model of SOA
•
Overview of Web Services
•
XML and XML Schema
•
The Communication Protocol
•
Web Services Description
•
Web Services Flow Description
• As a distributed computing architecture, Web Services are the most important implementation for SOA.
• SOA Model is Web Services Concept Architecture.
Concept in SOA Model
• Role – Services Provider – Services Requestor – Services Registry • Operation – Publish – Find – Bind • Key Component – Services – Services DescriptionCore Standards in SOA Model
• Some Standards
– Web Services Description Language (WSDL)
– Universal Description, Discovery and Integration (UDDI)
– Simple Object Access Protocol (SOAP)
– Web Service Flow Language
Process in SOA Development
Business Component Analysis Services Identification
Services Specification Component Identification Component Specification Services Realization Decision SOA Implementation
The Level Model of SOA Development
Existing Application Resources Components Services Business Process Services Provider Services Consumer
Qos Security Management
Relationship Between SOA and Web
Services
• Based on open standard and flexible implementation, Web
services is natively applicable to SOA implementation.
• The Relationships between Web services and SOA are:
– Web services provide an open standard and machine-readable model (WSDL) for creating explicit, implementation-independent descriptions
of service interfaces.
– Web services provide communication mechanisms that are location-transparent and interoperable.
– Web services are evolving through BPEL4WS, document-style SOAP, and WSDL, and emerging technologies such as WS-ResourceFramework to
Web Services
• The Web: Flexible human-machine interaction• Web Services: Web services are a recent set of technology
specifications that leverage existing proven open standards such as XML, URL, and HTTP to provide a new system-to-system
communication standard.
• Working Definition: Network-resident software Services accessible via standardized protocols
– Simple Object Access Protocol (SOAP): very flexible remote procedure call
• Lots of interest in trade press, academic community, standards bodies, . . .
Categories of Web Services
•
Business-Oriented Web Services
– ERP,CRM,
– Application system integration
•
Consumer-Oriented Web Services
– B2C website, across multi B2C systems
•
Device-Oriented Web Services
– Support the services across different kinds of services. E.g weather report, email service
•
System-Oriented Web Services
– Authentication
– Monitoring
The Processes of Web Services
Simplify and/or automate web Services
• Discovery
– What properties should be described? – How to efficiently query against them?
• Composition
– Specifying goals of a composition
– Specifying constraints on a composition – Building a composition
– Analysis of compositions
• Invocation
– Keeping enactments separated – Providing transactional guarantees
Web Services Standard Stack
XML messaging layer: SOAP , WS-Addressing, WS-Notification, WS-Eventing,
WS-Enumeration, WS-MessageDelivery, WS-Reliability,WS Reliable Messaging, WS-Resources WS-Transfer
Services Description Layer: WSDL, WSCL, WSCI,WS-MetadataExchange, WS-Policy Web Services composition: WSFL,BPEL4WS WS-CDL WS-CAF Publishing and discovery: UDDI, WSIL , WS-Discovery Web Services Transaction: WS-Coordination WS-Transaction WS-AtomicTransaction WS-BusinessActivity Web Services Management: WSDM, WS-Manageability SPML, WS-Provisioning Web Services Security: XML-Encryption XML-Signature WS-Security WS-SecureConversatio n WS-SecurityPolicy WS-Trust
Data Type Interface Behavior Message BPEL
Web Service Standards Implementation Platforms
WSDL SOAP
XML Schema
XML Sun J2EE
Web Service Core Standards
Microsoft .Net
The structure of XML
• Tag: label for a section of data
• Element and Subelement: section of data beginning with <tagname> and ending with matching </tagname>
Elements must be properly nested
– Proper nesting
• <account> … <balance> …. </balance> </account>
– Improper nesting
• <account> … <balance> …. </account> </balance>
– Formally: every start tag must have a unique matching end
– Every document must have a single top-level element
<bank>
<customer>
<name> Hayes </name> <street> Main </street> <city> Harrison </city> <account>
<account-number> A-102 </account-number> <branch-name>Perryridge </branch-name> <balance> 400 </balance> </account> <account> … </account> </customer> . . </bank>
The structure of XML
The structure of XML
•
Attribute
– Elements can have attributes
<account acct-type = “checking” >
<account-number> A-102 </account-number> <branch-name> Perryridge </branch-name> <balance> 400 </balance>
</account>
– Attributes are specified by name=value pairs inside the starting tag of an element
– An element may have several attributes, but each attribute name can only occur once
The structure of XML
•
Differences between element and attribute
attributes cannot be nested
<customer name=Hayes street=Main city=Harrison> <account>
<account-number> A-102 </account-number> <branch-name> Perryridge </branch-name> <balance> 400 </balance> </account> <account> … </account> </customer>
The structure of XML
•
Well-Formed XML Documents
–
There is only one outermost element in the
document (called the root element)
–
Each element contains an opening and a
corresponding closing tag
–
Tags can not overlap, as in
<author><name>LeeHong</author></name>
–
Attributes within an element have unique names
–
Element and tag names must be permissible
The structure of XML
•
The Tree Model of XML Documents
–
There is exactly one root
–
There are no cycles
–
Each node, other than the root, has exactly
one parent
–
Each node has a label. Element or attribute
–
The order of elements is important
Namespace
•
XML data has to be exchanged between organizations
•
Same tag name may have different meanings in
different organizations, causing confusion on
exchanged documents
•
Specifying a unique string as an element name avoids
confusion
•
Better solution: use
unique-name:element-name
•
Avoid using long unique names all over document by
using XML Namespaces
Namespace
<Schema name="mySchema" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:myNS=http://www.xml_step_by_step.edu\ns.xml > Three namespaces: schema namespace datatype namespace myNS namespaceXML Schema
• Database schemas constrain what information can be stored,
and the data types of stored values
• schemas are very important for XML data exchange
– Otherwise, a site cannot automatically interpret data received from another site
• Two mechanisms for specifying XML schema
– Document Type Definition (DTD) – XML Schema
XML Schema
•
XML Schema Supports
–
Typing of values
• E.g. integer, string, etc
• Also, constraints on min/max values
–
User defined types
–
Is itself specified in XML syntax, unlike DTDs
• More standard representation, but verbose
–
Is integrated with namespaces (reuse and refine)
–
Many more features
<xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema> <xsd:element name=“bank” type=“BankType”/>
<xsd:element name=“account”> <xsd:complexType>
<xsd:sequence>
<xsd:element name=“account-number” type=“xsd:string”/> <xsd:element name=“branch-name” type=“xsd:string”/> <xsd:element name=“balance” type=“xsd:decimal”/> </xsd:squence>
</xsd:complexType> </xsd:element>
….. definitions of customer and depositor ….
<xsd:complexType name=“BankType”> <xsd:squence>
<xsd:element ref=“account” minOccurs=“0” maxOccurs=“unbounded”/> <xsd:element ref=“customer” minOccurs=“0” maxOccurs=“unbounded”/> <xsd:element ref=“depositor” minOccurs=“0” maxOccurs=“unbounded”/> </xsd:sequence>
XML Schema
•
Element Types
<element name=". . ."/> with possible attributes: – ‘ type’ attribute
define the element type of this element: type=". . ." (more on types later)
– cardinality constraints:
• minOccurs="x", where x may be any natural number (including zero)
• maxOccurs="x", where x may be any natural number (including zero) or unbounded
XML Schema
<element name="email"/>
<element name="head" minOccurs="1"
maxOccurs="1"/>
XML Schema
•
Attribute Types
<attribute name=". . ."/> with possible
attributes
–
type=". . ."
–
use="x", corresponds to #OPTIONAL and #IMPLIED
in DTDs
–
use="x" value=". . .", where x may be default
or fixed
XML Schema
<attribute name="id" type="ID"
use="required"/>
<attribute name="speaks"
type="LanguageType" use="default“
value="en"/>
XML Schema
•
Data Types
–
Numerical data types, including integer, Short,
Byte, Long, Float,Decimal
–
String data types, including string, ID, IDREF,
CDATA, Language
–
Date and time data types
•
user-defined data types
XML Schema
•
Complex data type and extension data type
– defined from already existing data types by defining some attributes (if any) and using sequence, all and choice.
<complexType name="lecturerType"> <sequence>
<element name="firstname" type="string" minOccurs="0" maxOccurs="unbounded"/> <element name="lastname" type="string"/> </sequence>
<attribute name="title" type="string" use="optional"/> </complexType>
XML Schema
• <element name=“lecture” type=“lectureType”>
<lecture title=“associate professor”> <firstname>gang</firstname> <lastname>Huang</lastname> </lecture>
XML Schema
Data Type Extension: existing data types can be
extended by new elements or attributes
<complexType name="extendedLecturerType"> <extension base="lecturerType">
<sequence>
<element name="email" type="string" minOccurs="0" maxOccurs="1"/>
</sequence>
<attribute name="rank" type="string" use="required"/> </extension>
XML Schema
•
Restriction data type and simple data type
be defined by restricting existing data types
<complexType name="restrictedLecturerType"> <restriction base="lecturerType">
<sequence>
<element name="firstname" type="string" minOccurs="1" maxOccurs="2"/>
</sequence>
XML schema
•
Simple data types can also be defined by
restricting existing data types.
<simpleType name="dayOfMonth">
<restriction base="integer">
<minInclusive value="1"/>
<maxInclusive value="31"/>
</restriction>
</simpleType>
The Communication Protocol
(SOAP)
Why
S
imple
O
bject
A
ccess
P
rotocol
• SOAP is an XML messaging protocol that is independent of any specific transport protocol.
• Light weight replacement for complicated distributed object technology
• Originally for BizTalk (Microsoft/UserLand/DevelopMentor )
• Now a W3C standard
SOAP Message Structure
• Envelope contains – Header – Body • Header is optional – Out-of-band information such as… • Authentication information • Message routes • Logging • Transaction flowSOAP Envelope
SOAP Header Header Block Header Block . . . SOAP Body Body Block . . .SOAP 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-ncoding"> <soap:Body> <m:GetPrice xmlns:m="http://www.w3schools.com/prices"> <m:Item>Apples</m:Item> </m:GetPrice> </soap:Body> </soap:Envelope>SOAP 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"> <soap:Body> <m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices"> <m:Price>1.90</m:Price> </m:GetPriceResponse> </soap:Body> </soap:Envelope>Web Services Description Language
(WSDL)
•
WSDL is an XML-based interface definition language
that separates function from implementation, and
enables design by contract as recommended by SOA.
•
WSDL defines
–
What does Services do –
interface
–
Access specification –
how
Ingredients of WSDL
Operation
Port Type
Message
Binding
Port
Services
SupportsInput & Output
Provides How to encode Formats & Protocols
How to invoke
Implements
Interface
Access
Main Structure of WSDL
<definitions namespace = “http://… ”> <types> XML schema types </type>
<message> definition of a message </message> <portType> a set of operations </portType>
<binding> communication protocols </binding> <Services> a list of binding and ports </Services> </definitions>
49
Types
• <types> define data types used in defining messages
• XML Schema, DTD, and etc.
• XML Schema must be supported by any vendor of WSDL
conformant products
<types>
<schema targetNamespace=“http://example.com/stockquote.xsd”
xmlns=“http://www.w3.org/2000/10/XML Schema”>
<element name=“TradePriceRequest”> <complexType>
<all>
<element name=“tickerSymbol” type=“string“
minOc cur = “1” maxOccur=“10”/>
<element name = “payment”> <complexType>
<choice>
<element name = “account” type=“string” />
<element name = “creditcard” type=“string” /> </choice> </complexType> </element> </all> </complexType>
WSDL Messages
• A <message> element defines the data elements of an operation
• Each message can be the input or output of an operation, and may consist of one or more parts
• A part resembles a parameter of a function <message name=“GetLastTradePriceInput”>
<part name=“body” element="TradePriceRequest"/> </message>
WSDL PortTypes
• The <portType> element is the most important WSDL element: it defines
– a web Services
– the operations that can be performed, and – the messages that are involved
• The <port> defines the connection point to a web Services, an instance of <portType>
– It can be compared to a function library (or a module, or a class) in a traditional programming language
– Each operation can be compared to a function in a traditional programming language
<portType name=“StockQuotePortType”> <operation name=“GetLastTradePrice”>
<input message=“tns:GetLastTradePriceInput” /> <output message=“tns:GetLastTradePriceOutput” /> </operation>
Operation Types
• The request-response type is the most common operation
type, but WSDL defines four types:
– One-way: The operation can receive a message but will not return a response
– Request-response: The operation can receive a request and will return a response
– Solicit-response: The operation can send a request and will wait for a response
– Notification: The operation can send a message but will not wait for a response
Operation Types
One-way:
• <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 > Request-response :
<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"/>
• Binding defines how message are transmitted, and the location of the Services
• <binding> element has two attributes: – type: the port type
– name: name of the binding
• <soap:binding> has two attributes: – style: either “document” or “rpc”
– transport: protocol to use, e.g., “http”
Binding
<binding name="StockQuoteSoapBinding“ type="tns:StockQuotePortType"> <soap:binding style=“document” transport=“http://schemas.xmlsoap.org/soap/http” /> <operation name="GetLastTradePrice"> <soap:operation soapAction=“http://example.com/GetLastTradePrice” /> <input> <soap:body use=“literal” /> </input> <output> <soap:body use=“literal” /> </output> </operation> </binding><Services name=“StockQuoteServices”> <documentation> My first Services </documentation> <port name=“StockQuotePort” binding=“tns:StockQuoteBinding”> <soap:address location=“http://example.com/stockquote” /> </port> </Services>
Services
Summary of WSDL
•
Types
•
Message
•
Operation
•
PortType
•
Binding
•
Port
•
Service
Business Process Execution Language
• Define business processes as coordinated sets of Web Services interactions
• Define both abstract and executable processes
• Enable the creation of compositions of Web Services
• Where it comes from:
– Strong roots in traditional flow models
– Concepts from structured programming languages
– On the top of WSDL and core XML specifications
– Merges WSFL and XLANG concepts
• The OASIS WS BPEL Technical Committee is advancing the
Structure of a BPEL Process
• Web Services the process
interacts with
• Data used by the process
• Used to support asynchronous
interactions
• Alternate execution path to deal with faulty conditions
• Code to execute when
“undoing” an action
• What the process actually does <process ...> <partners> ... </partners> <messageExchanges> ... </ messageExchanges > <correlationSets> ... </correlationSets> <faultHandlers> ... </faultHandlers> <compensationHandlers> ... </compensationHandlers> (activities)*
• A partner is accessed over a WS “channel”, defined by a Services link type
• A SLT defines two roles and the portTypes that each role needs to support
Partner Definitions and Links
<partner name=“...” ServicesLinkType=“...” partnerRole=“...” myRole=“...”/> <ServicesLinkType name=“...”> <role name=“..."> <portType name=“...” />* </role> <role name=“...”> <portType name=“...”/>*
Containers Definition
<containers>
<container name=“…"
messageType=“…"/>
<container name=“…"
messageType=“…"/>
</containers>
• Invokes an operation on a partner
• Receives invocation from a partner
• Sends a reply message in partner invocation
• Data assignment between containers
<assign> <copy>
<from container=“...”/> <to container=“...”/>
BPEL Basic Activities
<invoke partner=“...” portType=“...” operation=“...”
inputContainer=“...” outputContainer=“...”/>
<receive partner=“...” portType=“...” operation=“...” container=“...” [createInstance=“...”] />
<reply partner=“...” portType=“...” operation=“...”
• Detects processing error and switches into fault processing mode
• Pull the plug on this instance
• Execution stops for a specified amount of time
• Do nothing; a convenience element
More Basic Activities
<wait for=“...”? until=“...”? />
<throw faultName=“...” faultContainer=“...”/>
<terminate/>
• A <sequence> activity contains one or more activities that are performed sequentially.
• The <pick> activity waits for the occurrence of exactly one event from a set of events, thenexecutes the activity associated with that event.
• The <flow> activity provides concurrency and synchronization.
• The<swith>activity provides optional activity.
BPEL Structured Activities
<flow standard-attributes>activity+</flow>
<sequence standard-attributes>activity+</sequence>
<pick createInstance="yes|no"? standard-attributes>…<pick>
<swith standard-attributes> <case>…</case>
• The <while> activity provides for repeated execution of a contained activity.
• The <repeatUntil> activity provides for repeated execution of a contained activity.
• The <if> activity provides conditional behavior.
More Structured Activities
<if standard-attributes>standard-elements <condition>…</condition>activity <elseif>*<condition>…</condition>activity</elseif> <while standard-attributes><condition>..</condition>activity</while> <repeatUntil standard-attributes>activity <condition>…</condition></repeatUntil>
<sequence>
execute activities sequentially
<flow>
execute activities in parallel
<while>
iterate execution of activities until condition is violated
<pick>
several event activities (receive message, timer event)
scheduled for execution in parallel; first one is selected and corresponding code executed
<link ...>
A Activities Use Case
Flow Seq Seq Seq While <sequence> <receive .../> <flow> <sequence> <invoke ... /> <while ... > <assign> ... </assign> </while> </sequence> <sequence> <receive ... /> <invoke ... /> </sequence> </flow>
Web Services Publication and
Discovery
UDDI
•
UDDI servers act as a directory of available services
and service providers. SOAP can be used to query
UDDI to find the locations of WSDL definitions of
services, or the search can be performed through a
user interface at design or development time.
•
Data structure specification describes what kind of
data is stored in UDDI.
•
The programmer’s API specification contains how a
UDDI registry can be accessed.
•
The replication specification contains descriptions of
how registries replicate information among
UDDI
•
Three basic functions
–
publish:how to register a web service
–
Search: how to find a specific web service
–
binding: How to connect to a web service
UDDI Registries
UDDI registries contains information about
businesses and the Services these businesses
offer.
–
Public registries
–
Private registries
Public Registries
• IBM Public registry Registration:
https://uddi.ibm.com/ubr/registry.html
inquiryURL= https://uddi.ibm.com/ubr/inquiryapi publishURL= https://uddi.ibm.com/ubr/publishapi
• Test registry Registration:
https://uddi.ibm.com/testregistry/registry.html
inquiryURL= https://uddi.ibm.com/testregistry/inquiryapi publishURL= https://uddi.ibm.com/testregistry/publishapi
Public Registries
• HP Registration: http://uddi.hp.com inquiryURL = http://uddi.hp.com/ubr/inquire publishURL = https://uddi.hp.com/ubr/publish • Microsoft Registration: http://uddi.rte.microsoft.com inquiryURL=http://uddi.rte.microsoft.com/inquire publishURL=https://uddi.rte.microsoft.com/publish • SAP Registration: http://udditest.sap.comPrivate UDDI Registries
• Operate your own registry for testing purposes
• Establish your own registry of Services for your own organization
Summary
• As a distributed computing architecture,Web Services are the most important implementation for SOA;
• Web Services: Flexible machine-machine interaction;
• XML is a powerful language to describe data. It’s construct rules is defined by XML Schema.
• SOAP is a light weight replacement for complicated distributed object technology which we use to wrap Web Services message; • The function and interface of Web Services is open by WSDL
and the interaction between Web Services is presented by BPEL;
• Universal Description, Discovery, and Integration (UDDI) is a technical specification for describing, discovering, and
Reference
•SOA & Webservices.http://www-900.ibm.com/developerWorks/cn/ webservices
•WebServices. http://www.w3.org/2002/ws/
•Ueli Wahli ,Thomas Kjaer…“WebSphere Version 6 Web Services Handbook Development&Deployment”,http://www.redbooks.ibm.com
/redbooks/pdfs/sg246461.pdf,2005
•Stan Kleijnen,Srikanth Raju.An Open Web Services Archiecture.NewYork: ACM Press,2003
•XML.http://www.w3.org/TR/xml/
•XML Schema. http://www.w3.org/TR/xmlschema11-1/
•XML Schema. http://www.w3.org/TR/xmlschema11-2/ •WSDL. http://www.w3.org/TR/wsdl
•Tony Andrews, Francisco Curbera…Business Process Execution Language for Web Services Version 1.1.http://download.boulder.ibm.com/
ibmdl/pub/software/dw/specs/ws-bpel/ws-bpel.pdf
•The Stencil Group.” The Evolution of UDDI ,UDDI.org White Paper” http://www.uddi.org/pubs/the_evolution_of_uddi_20020719.pdf