Documente Academic
Documente Profesional
Documente Cultură
Juanzi Li
Department of Computer Science and Technology Tsinghua University Mar. 2007
Outline
The Model of SOA Overview of Web Services XML and XML Schema The Communication Protocol Web Services Description Web Services Flow Description Web Services Publication and Discovery
SOA Model
As a distributed computing architecture, Web Services are the most important implementation for SOA. SOA Model is Web Services Concept Architecture.
Integration Architecture
Services
Components
11
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, . . . Applications in e-commerce, telecom, science, GRID, government, education, . . .
12
Composition
Specifying goals of a composition Specifying constraints on a composition Building a composition Analysis of compositions
Invocation
Keeping enactments separated Providing transactional guarantees
Monitoring
How to track enactments Recovering from failed enactments
14
Services Description Layer: WSDL, WSCL, WSCI,WS-MetadataExchange, WS-Policy XML messaging layer: SOAP , WS-Addressing, WS-Notification, WS-Eventing, WS-Enumeration, WS-MessageDelivery, WS-Reliability,WS Reliable Messaging, WS-Resources WS-Transfer Transport layer: HTTP, SMTP, FTP, etc.
15
BPEL
IBM WebSphere WSDL SOAP XML Schema
Message
Type Data
Microsoft .Net
XML
Web Service Standards
Implementation Platforms
16
Sun J2EE
17
Improper nesting
Formally: every start tag must have a unique matching end tag, that is in the context of the same parent element.
18
. </bank>
<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
<account acct-type = checking monthly-fee=5>
20
21
23
24
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
25
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 namespace
26
XML 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
27
XML Schema
XML Schema Supports
Typing of values
E.g. integer, string, etc Also, constraints on min/max values
<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> </xsd:complexType> </xsd:schema>
29
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
30
XML Schema
<element name="email"/> <element name="head" minOccurs="1" maxOccurs="1"/> <element name="to" minOccurs="1"/>
31
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
32
XML Schema
<attribute name="id" type="ID" use="required"/> <attribute name="speaks" type="LanguageType" use="default value="en"/>
33
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
34
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>
35
XML Schema
<element name=lecture type=lectureType> <lecture title=associate professor> <firstname>gang</firstname> <lastname>Huang</lastname> </lecture>
36
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> </complexType>
37
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> <attribute name="title" type="string" use="required"/> </restriction> </complexType>
38
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>
39
40
41
Envelope contains Header Body Header is optional Out-of-band information such as Authentication information Message routes Logging Transaction flow Body contains XML body of RPC call
42
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>
43
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>
44
45
Ingredients of WSDL
Supports Interface
Port Type
Operation
Input & Output
How to encode
Message
Port
Provides
Services
Endpoints
47
48
Types
<types> <types> define data types used in defining messages <schema targetNamespace=http: //example.com/stockquote.xsd xmlns=http://www.w3.org/2000/10/XMLSchema> <element XML Schema, DTD, and etc.> name=TradePriceRequest <complexType> XML Schema must be supported by any vendor of WSDL <all> <element products name=tickerSymbol type=string conformant minOccur = 1 maxOccur=10/> <element name = payment> <complexType> <choice> <element name = account type=string /> <element name = creditcard type=string /> </choice> </complexType> </element> </all> </complexType> </element> </schema> </types>
49
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> <message name=GetLastTradePriceOutput> <part name=body element=TradePrice /> </message>
50
WSDL PortTypes
The <portType> element is the most important WSDL element: it defines a web Services <portType StockQuotePortType > and thename= operations that can be performed, <operation name=GetLastTradePrice the messages that are involved > <input message=tns:GetLastTradePriceInput /> The <port> defines the connection point to a web Services, <output message=tns:GetLastTradePriceOutput /> an instance of <portType> </operation> It can be compared to a function library (or a module, </portType> or a class) in a traditional programming language Each operation can be compared to a function in a traditional programming language
51
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 WSDL 1.2 adds: request multiple response
52
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"/> </operation> </portType> 53
Binding
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
54
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>
55
Services
<Services name=StockQuoteServices> <documentation> My first Services </documentation> <port name=StockQuotePort binding=tns:StockQuoteBinding> <soap:address location=http://example.com/stockquote /> </port> </Services>
56
Summary of WSDL
Types Message Operation PortType Binding Port Service
57
58
59
60
<partners> ... </partners> <messageExchanges> ... </ messageExchanges > <correlationSets> ... </correlationSets> <faultHandlers> ... </faultHandlers> <compensationHandlers> ... </compensationHandlers>
(activities)*
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>
61
A SLT defines two roles and the portTypes that each role needs to support <ServicesLinkType name=...> <role name=..."> <portType name=... />* </role> <role name=...> <portType name=.../>* </role> </ServicesLinkType>
62
Containers Definition
<containers> <container name=" messageType="/> <container name=" messageType="/> </containers>
63
Execution stops for a specified amount of time <wait for=...? until=...? /> Do nothing; a convenience element
<empty/>
65
The <pick> activity waits for the occurrence of exactly one event from a set of events, thenexecutes the activity associated with that event.
<pick createInstance="yes|no"? standard-attributes><pick>
69
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 programmers API specification contains how a UDDI registry can be accessed. The replication specification contains descriptions of how registries replicate information among themselves.
70
UDDI
Three basic functions
publishhow to register a web service Search: how to find a specific web service binding: How to connect to a web service
71
UDDI Registries
UDDI registries contains information about businesses and the Services these businesses offer. Public registries Private registries
72
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
73
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.com inquiryURL=http://uddi.sap.com/UDDI/api/inquiry/ publishURL=https://uddi.sap.com/UDDI/api/publish/
74
75
Summary
As a distributed computing architectureWeb Services are the most important implementation for SOA; Web Services: Flexible machine-machine interaction; XML is a powerful language to describe data. Its 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 integrating web Services.
76
Reference
SOA & Webservices.http://www-900.ibm.com/developerWorks/cn/ webservices WebServices. http://www.w3.org/2002/ws/ Ueli Wahli ,Thomas KjaerWebSphere 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 CurberaBusiness 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 Java Web Services Application and development, Publication House of
77