ICT 1 INF5120 Modellbasert systemutvikling Web Services XML Schema WSDL BPEL Forelesning 26.03.2007...
-
date post
19-Dec-2015 -
Category
Documents
-
view
218 -
download
0
Transcript of ICT 1 INF5120 Modellbasert systemutvikling Web Services XML Schema WSDL BPEL Forelesning 26.03.2007...
1ICT
INF5120Modellbasert systemutvikling
Web Services XML Schema WSDL BPEL
Forelesning 26.03.2007
Roy Grø[email protected]
2ICT
Outline
Web Services – Infrastructure and Architecture XML Introduction XML Schema
Web Service Description Language (WSDL) Business Process Execution Language (BPEL)
3ICT
Web Services – Infrastructure and Architecture
4ICT
What is a Web service?
The term “Web services” is confusing. There are many things that are referred to as “Web
services”. Adding to the confusion is the term “services” which is
interpreted differently by different people.
5ICT
WebWeb serviceservice
Web is short for World Wide Web.
Work performed or offered by a software system (possibly including human resources as well.)
Software services performed or offered on the Web, using open Internet standards and technologies.
What is a Web service?
6ICT
Definition (W3C): Web service
“A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.”
- W3C Web Services Glossary, http://www.w3.org/TR/ws-gloss/
7ICT
Characteristics of a basic Web service
Fundamental requirements: It receives service requests and sends service replies over HTTP
Service requests – input data/parameters Service responses – output data/parameters
Data is normally formatted as an XML document SOAP (Simple Object Access Protocol)
Interface w/ operations and associated bindings and protocols are described using WSDL
Additionally, a Web service may: Be registered with a discovery agent through which it can be
located, typically UDDI.
8ICT
Transports
Messaging
Description
ComposableService
Assurance
ServiceComposition
HTTP HTTPS SMTP
XML SOAP WS-Addressing
XSD WSDL UDDI WS-PolicyWS-Metadata
Exchange
WS-SecurityWeb Service ReliableMessaging (WS-RM)
WS-Transactions
WS-BPEL
Web services stack
Technologystack
Conceptualstack
This part of the tutorial focuses on understanding the Web service technologies for messaging, description and composition such as XSD, WSDL and WS-BPEL.
9ICT
Web services – a conceptual view
Underlying Protocols
Messaging Encoding
Business EntitiesWeb Service Interfaces
HTTP/WEB
VANsFTP
SMTP/EMAIL MQ-Series
SOAP
EDI“Binary”
Raw XML ebXML
BPEL
____________________________________________________________
EGO-CentricWorkflow ProcessDescription
WSDL
____________________________________________________________
(Syntactic) Web Service Interface Description
Bindings and Endpoint Descriptions
WS-CHOR
____________________________________________________________
Interaction Sequencing
(Co)Constraints
XSD
____________________________________________________________
XML MessageSchemaDefinition
10ICT
Web Services Architecture
BPEL
11ICT
Relationship between Architecture model and Web Services
BPEL
WSDL
XML Schema
UML Activity
UML Interface
UML Class
12ICT
Model-driven Web Services –Two alternatives
Web Service (XML, Textual)
Model-to-modelPIM
(COMET models)
transformation
PSM (WS UML Profile)
Model-to-textModel-to-text
1
2
1
1. Transformation in two steps via UML profile
ATL
MOFScript MOFScript
2. Transformation in one step
Transformation choices:• fixed• config file• user is prompted
13ICT
XML Introduction
14ICT
XML - a Metameta Language
Metameta/How to define schema
Meta/Schema
Instances/Documents
XML SGML
MathML XSL SMIL OFX HTML
XSL Doc HTML Doc
XML Doc
15ICT
DocumentType
Definition(DTD)
XMLDocument
XSL(T)to rearrange/restructure
an XML document…
and to prepare a document
for rendering based on an XSL document
XPointerto positiona cursor
in an XMLdocument
XLinkto createcomplex
links
XML Schemato represent the DTD in
XML syntax and expressadditional constraints
XML Queryto query sets ofXML documents
RDFResource
DescriptionFramework -
to add metadata
OGI DISC - modified and extended by SINTEF Slide 16
Example XML Document
<?XML version="1.0"?>
<memo clearance-level = “0” status = “draft”>
<memo-header>
<from>Brian Smith</from>
<to>Mary Brown</to>
<date>March 3, 1998</date>
<subject>excessive overtime</subject></memo-header>
<memo-body><para>The Flame Project team has been working overtime for weeks and weeks. Let’s take the group to lunch on Friday. </para></memo-body>
</memo>
OGI DISC - modified and extended by SINTEF Slide 17
Example XML Document
Start- and end-tagscome in pairs
<?XML version="1.0"?>
<memo clearance-level = “0” status = “draft”>
<memo-header>
<from>Brian Smith</from>
<to>Mary Brown</to>
<date>March 3, 1998</date>
<subject>excessive overtime</subject></memo-header>
<memo-body><para>The Flame Project team has been working overtime for weeks and weeks. Let’s take the group to lunch on Friday. </para></memo-body>
</memo>
OGI DISC - modified and extended by SINTEF Slide 18
the content of simple elements:appears between start tag and end tag
<?XML version="1.0"?>
<memo clearance-level = “0” status = “draft”>
<memo-header> Text content
<from>Brian Smith</from>
<to>Mary Brown</to>
<date>March 3, 1998</date>
<subject>excessive overtime</subject></memo-header>
<memo-body><para>The Flame Project team has been working overtime for weeks and weeks. Let’s buy pizza for the group on Friday. </para></memo-body>
</memo>
OGI DISC - modified and extended by SINTEF Slide 19
the content of compound elements:appears between start tag and end tag
<?XML version="1.0"?>
<memo clearance-level = “0” status = “draft”>
<memo-header>
<from>Brian Smith</from>
<to>Mary Brown</to>
<date>March 3, 1998</date>
<subject>excessive overtime</subject></memo-header>
<memo-body><para>The Flame Project team has been working overtime for weeks and weeks. Let’s buy pizza for the group on Friday. </para></memo-body>
</memo>
a compound elementincludes all of the completesubelements: the tags andcontent of the subelements
OGI DISC - modified and extended by SINTEF Slide 20
Attributes in XML
In the document, we see:
<memo clearance-level = “0” status = “draft”>
Attributes are associated with elements….and the assignment of values to attributes always appear in the start tag for the element.
attribute name
tag name
attribute value
attribute name
attribute value
OGI DISC - modified and extended by SINTEF Slide 21
Namespaces Example
Slightly modified listings document<?xml version="1.0">
<Recent-Listings Area="Raleigh Hills" Date="March 97”
xmlns=“http://www.century21.com/listings.dtd”
xmlns:mls="urn:uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" >
<For-Sale>
<Home id="h1">
<Address>8225 SW Canyon Lane</Address>
<mls:Structure>
<Num-Beds>3</Num-Beds>
<Num-Baths>2</Num-Baths>...
DefaultNamespace
“Named”Namespace
Prefix
22ICT
XML is extensively used – Examples
XML Metadata Interchange (XMI) XSLT – programming language for transformation Web Services: XML Schemas, WSDL, SOAP, BPEL Storage/Exchange formats Configuration files Advantage: Tool support for parsing, validation, editing,
visualization, ease of debugging etc. Disadvantage: Poor readability, efficiency (compared to
binary)
23ICT
XML Schema
24ICT
XML Schema Definition (XSD)
Define the legal building blocks of an XML document: Defines elements that can appear in a document. Defines attributes that can appear in a document. Defines which elements are child elements. Defines the order of child elements. Defines the number of child elements. Defines whether an element is empty or can include text. Defines data types for elements and attributes. Defines default and fixed values for elements and attributes.
25ICT
Simple types
Simple types are defined by restricting a built-in-type or another simple type
<simpleType name=“age”>
<restriction base=“integer”>
<minInclusive value=“0”/>
<maxInclusive value=“130”/>
</restriction>
</simpleType>
fourteen facets to restrict including: pattern, enumeration, length(3), period and duration
26ICT
Another Example
<simpleType name="US-Flag-Colors"> <restriction base="string"> <enumeration value="red"/> <enumeration value="white"/> <enumeration value="blue"/> </restriction></simpleType>
27ICT
Defining complex types
<xsd:complexType name="Address" >
<xsd:sequence>
<xsd:element name="name" type=”xsd:string" />
<xsd:element name="street" type=”xsd:string" />…
<xsd:element name="zip" type=”xsd:decimal" />
</xsd:sequence>
<attribute name=”country" type=”xsd:string" />
</xsd:complexType>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="Address" />
...
</xsd:complexType>
28ICT
Document instance of purchase order
<PurchaseOrder orderDate="1999-05-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<state>CA</state>
<zip>90952</zip>
</shipTo>
...
</PurchaseOrder>
type="Address"
name=“shipTo"
29ICT
<complexType> or <simpleType>?
When do you use the complexType element and when do you use the simpleType element? Use the complexType element when you want to define child
elements and/or attributes of an element Use the simpleType element when you want to create a new type
that is a refinement of a built-in type (string, integer, etc)
30ICT
Defining attributes
<attribute name="Category" use="required"> <simpleType> <restriction base="string"> <enumeration value="autobiography"/> <enumeration value="non-fiction"/> <enumeration value="fiction"/> </restriction> </simpleType></attribute>
• Note: attributes can only have simpleTypes (i.e., attributes cannot have child elements).
Anonomous type
31ICT
Notes about Attributes
The attribute declarations always come last, after the element declarations.
The attributes are always with respect to the element that they are defined (nested) within.
<element name="foo"> <complexType> <sequence> … </sequence> <attribute name="bar" …/> <attribute name="boo" …/> </complexType></element>
"bar and boo areattributes of foo"
32ICT
Inheritance: Extending complex types
<complexType name="USAddress">
<extension base="Address"> <sequence> <element name="zip"
type="xsd:string"/> </sequence>
</extension></complexType>
33ICT
Elements
<element name="zip” type="xsd:string"/>
tag name ininstance document
type is either built-in types,simpleTypes or complexTypes
<zip>90210</zip>
XML instance:
34ICT
XSD: XML text editor
Can also be built using simple text editors XML editors gives contextual support, e.g. like auto-completion, suggestions
for elements, etc., as well as validation of the XML document.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:schema> Inside here goes:• elements• complexTypes• simpleTypes
35ICT
XSD: UML profile for XSD
UML representation of XML schema.
Useful in a UML-centric development method if the modelling environment supports generation/import of XSD documents.
36ICT
PIM4SOA main mappings to XSD
PIM4SOA
element
XSD equivalent Notes
Document Schema
Entity ComplexType
Association Element An association between entities is transformed into an
element in the containing type with a reference to the
complex type generated for the target Entity
Attribute Attribute Attributes having simple types are mapped to Attributes
in complex types. Attributes with complex types in the
PIM4SOA model are mapped in the same way as
Associations.
Element SimpleType If the ItemType from the PIM4SOA model is not an
entity (meaning it is a simple type) a SimpleType
definition is created in the schema.
37ICT
Web Service Description Language (WSDL)
38ICT
Making a SOAP function call over HTTP
Body
XMLData
Header
HTTP Request
Body
XMLData
Header
HTTP Response
39ICT
The SOAP Envelope
<SOAP:Envelope> <SOAP:Header></SOAP:Header>
<SOAP:Body> <m:FunctionName>
<paramName1>paramValue1</paramName1>
<paramName2>paramValue2</paramName2> </m:FunctionName> </SOAP:Body>
</SOAP:Envelope>
Optional
40ICT
Web Services Description Language (WSDL)
Purpose Web services need to be defined in a consistent manner so that
they can be discovered by and interfaced with other services and applications.
The Web Services Description Language is a W3C specification providing the foremost language for the description of Web service definitions.
W3C, "Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language", World Wide Web Consortium (W3C), W3C Working Draft, 3 August 2004. http://www.w3.org/TR/2004/WD-wsdl20-20040803/
41ICT
WSDL: Conceptual view
Underlying Protocols
Messaging Encoding
Business EntitiesWeb Service Interfaces
HTTP/WEB
VANsFTP
SMTP/EMAIL MQ-Series
SOAP
EDI“Binary”
Raw XML ebXML
WSDL
____________________________________________________________
(Syntactic) Web Service Interface Description
Bindings and Endpoint Descriptions
42ICT
WSDL: Conceptual model
WS Provider
WSClient
WS Interface
Ports
Operations
Name,Abstract Message Parts SchemaMessage Exchange Pattern
Porttype
Operation
Concrete Message EncodingConcrete Messaging Protocol
(Reusable) Binding
Concrete Endpoint Address
Operations Invoked through Ports
43ICT
WSDL: Message exchange patterns
WS Provider
WSClient
Time
Request-Response
Solicit-Response
One-Way
Notification
44ICT
WSDL 1.1 metamodel
WSDL DocumentWSDL Component
0..10..1
Port
+ Name
Operation
+ Name
Part
+ Name
+ Type
+ Element
Service
+ Name
1..*1..*
Binding
+ Name
1
1
1
1
Port Type
+ Name
11 11
Message
+ Name
1..*
0..1
1..*
+input
0..10..1
+output
0..10..1+fault 0..1
0..*0..*
Import
+ NameSpace
+ Location
Include
+ Location
Element
+ Name
+ BaseType
+ MinOccurs
+ MaxOccurs
Definition
+ Name
+ TargetNameSpace0..*0..*
0..*0..*0..*0..*
0..*0..*
0..*0..*
Schema
+ TargetNameSpaceTypes
0..10..1
A collection of related endpoints
A single endpoint defined as a combination of a binding and a network address
A concrete protocol and data format specification for a particular port type
An abstract set of operations supported by one or more endpoints
An abstract, typed definition of the data being communicated
An abstract, description of an action supported by the service
A container for data type definitions
45ICT
UML profile for WSDL
UML representation Text representation
46ICT
MyWebService<<BusinessService>>
BasicWFS
getCapabilities()describeFeatureType()getFeature()
<<Interface>>
TransactionWFS
lockFeature()transaction()
<<Interface>>
Payment
validate(card : CreditCard) : boolean
<<Interface>>
CreditCard
number : stringexpires : date
<types> <schema> <complexType name="CreditCard">...
<element name="number" type="string"/><element name="expires" type="date"/>...
</types> <message name="validateRequest"> <part name="card" type="CreditCard"/></message>... <portType name="Payment"> <operation name="validate">
<input message="validateRequest"/><output message="validateResponse"/>
</operation></portType> <portType name="TransactionWFS"> <operation name="getCapabilities">... <operation name="describeFeatureType">... <operation name="getFeature">... <operation name="lockFeature">... <operation name="transaction">... <binding name="PaymentSOAPBinding" type="Payment"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" ...>
<operation name="validate">...</binding> <binding name="TransactionWFSSOAPBinding" type="Payment"> <operation name="getCapabilities">... <operation name="describeFeatureType">... <operation name="getFeature">... <operation name="lockFeature">... <operation name="transaction">...</binding> <service name="myWebService"> <port name="Payment_Port”
binding="PaymentSOAPBinding"><soap:address location=”..www.myWebService.com"/>...
<port name="TransactionWFS_Port” binding="TransactionWFSSOAPBinding">…
Class
Copy-down Inheritance
Inte
rfac
e
BusinessService
Interface
Realize
47ICT
Business Process Execution Language (BPEL)
48ICT
BPEL
BPEL is a Web service composition language. It defineshow to compose other Web services so to accomplish amore complex task. A BPEL engine is capable of executing the composite service described by BPEL.
The outcome will be a composite BPEL-defined Web service which itself can be regarded as a Web service.
49ICT
BPEL language
XML notation Interaction with other Web services:
<receive>. Wait for an incoming message. Typically at the process start <invoke>. Call another Web service <reply>. Send a response message from the entire BPEL service
Control flow <sequence>. Sequential control flow <flow>. Parallel control flow <switch>. Conditional branching <while>. Loop
Data flow <variable>. Defines the data objects involved <assign>. Copy a data object from one variable to another possibly w/
data transformation
50ICT
BPEL: Simplified view
Web Service
portType
portType
portType
<receive>
<receive>
<reply>
<reply>
BPEL4WSProcess
A BPEL process is a composite Web service with a WSDL description.
51ICT
BPEL Foundations
52ICT
BPEL: Details• Two Uses
– Executable process descriptions– Business protocol descriptions – Abstract
processes• Partner links
– Paired WSDL interfaces– Correlation sets
Bind messages to process/activity instances.– Endpoint references
• Partner– Grouping constraint on partner links to a single
business partner.• Process Activities
– Basic - assign, throw, terminate, wait, empty, compensate
– Partner interaction - receive, reply, invoke– Structured - sequence, switch, while, pick,
flow, scope
Process
Partner - Links
WSDL PortType
53ICT
BPEL example
PO : POMessage
Invoice : InvMessage
receive
reply
shippingInfo
shippingSchedule
flow
sequence sequence sequence
54ICT
BPEL Process<process name="purchaseOrderProcess"
xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
<partnerLinks>
<partnerLink name="purchasing"
partnerLinkType="lns:purchasingLT"
myRole="purchaseService"/>
<partnerLink name="invoicing"
partnerLinkType="lns:invoicingLT"
myRole="invoiceRequester"
partnerRole="invoiceService"/>
<partnerLink name="shipping"
partnerLinkType="lns:shippingLT"
myRole="shippingRequester"
partnerRole="shippingService"/>
<partnerLink name="scheduling"
partnerLinkType="lns:schedulingLT"
partnerRole="schedulingService"/>
</partnerLinks>
55ICT
BPEL process
<sequence><receive partnerLink="purchasing" portType="lns:purchaseOrderPT" operation="sendPurchaseOrder" variable="PO"/><flow>
<links><link name="ship-to-invoice"/><link name="ship-to-scheduling"/>
</links><sequence>
<assign><copy>
<from variable="PO" part="customerInfo"/><to variable="shippingRequest" part="customerInfo"/>
</copy></assign>
...
56ICT
BPEL process
<invoke partnerLink="shipping"portType="lns:shippingPT" operation="requestShipping" inputVariable="shippingRequest" outputVariable="shippingInfo">
<source linkName="ship-to-invoice"/></invoke>
<receive partnerLink="shipping" portType="lns:shippingCallbackPT" operation="sendSchedule" variable="shippingSchedule">
<source linkName="ship-to-scheduling"/></receive>
...
57ICT
UML profile for BPEL
58ICT
PIM4SOA main mappings to BPEL
PIM4SOA element BPEL
equivalent
Notes
ServiceProviderProcess
Process
Task (i) (participating in collaboration) Receive, Invoke, Reply The type of communication with other service providers must be
deduced from parameters passed to or from the task in question.
Task (ii) (no collaboration use)
Empty This might be a task requiring further implementation or human
interaction beyond the scope of the PIM4SOA.
Flow Sequence, Flow, (…) The structure of flows between Steps must be analysed to deduce the
applicable BPEL structure.
Interaction, Pin Assign Interactions have a role to play both in determining collaboration type
(see Task (ii) above), and passing particular parts of messages
between tasks (data flow, a BPEL assign).
Message Variable All messages sent and received must have appropriate variables
defined within the BPEL
CollaborationUseRoleBinding
PartnerLink The CollaborationUses defined for the ServiceProvider tell us what
PartnerLinks we will need. See CollaborationUsePath.
CollaborationUsePath PartnerLink, Role(…) This defines a specific use of a PartnerLink, alongside what role we
are playing, and even the PortType being used. See links to the
WSDL transformation described below.
59ICT
RSM and UML profile for Web services
60ICT
Referanser, neste forelesning...
XML, XML Schema, WSDL: www.w3c.org BPEL: http://en.wikipedia.org/wiki/BPEL www.oasis-open.org
NB! Utskrift av foilene fra denne forelesningen blir lagt ut på neste forelesning.
Neste forelesning: 16.april, Interoperability and MDI – EIF and EIM (Brian)