
60cf0ad3eaeaf926a9a0274a22f372d3.ppt
- Количество слайдов: 60
INF 5120 Modellbasert systemutvikling Web Services XML Schema WSDL BPEL Forelesning 26. 03. 2007 Roy Grønmo roy. gronmo@sintef. no ICT 1
Outline Web Services – Infrastructure and Architecture XML Introduction XML Schema Web Service Description Language (WSDL) Business Process Execution Language (BPEL) ICT 2
Web Services – Infrastructure and Architecture ICT 3
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. ICT 4
What is a Web service? Web service 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. ICT 5
Definition (W 3 C): 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. ” - W 3 C Web Services Glossary, http: //www. w 3. org/TR/ws-gloss/ ICT 6
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. ICT 7
Web services stack Conceptual stack Technology stack This part of the tutorial focuses on understanding the Web service technologies for messaging, description and composition such as XSD, WSDL and WS-BPEL. ICT 8
Web services – a conceptual view WS-CHOR BPEL ___________ ______ EGO-Centric Workflow Process Description Interaction Sequencing (Co)Constraints ___________ ______ Business Entities Web Service Interfaces (Syntactic) Web Service Interface Description WSDL ___________ ______ Messaging Encoding Raw XML SOAP “Binary” Bindings and Endpoint Descriptions eb. XML EDI Underlying Protocols XSD ___________ ______ XML Message Schema Definition HTTP/WEB SMTP/EMAIL FTP MQ-Series VANs ICT 9
Web Services Architecture BPEL ICT 10
Relationship between Architecture model and Web Services UML Activity BPEL UML Interface UML Class WSDL XML Schema ICT 11
Model-driven Web Services – Two alternatives 1 PIM (COMET models) ATL PSM (WS UML Profile) Model-to-model MOFScript Model-to-text Transformation choices: • fixed • config file • user is prompted 1 Model-to-text 2 Web Service (XML, Textual) 1. Transformation in two steps via UML profile 2. Transformation in one step transformation ICT 12
XML Introduction ICT 13
XML - a Metameta Language Metameta/How to define schema Meta/Schema Instances/Documents XML SGML Math. ML XSL SMIL OFX HTML XML Doc XSL Doc ICT HTML Doc 14
XML Schema to represent the DTD in XML syntax and express additional constraints XSL(T) to rearrange/restructure an XML document … and to prepare a document for rendering based on an XSL document Document Type Definition (DTD) RDF Resource Description Framework to add metadata XML Document XPointer to position a cursor in an XML document XLink XML Query to query sets of XML documents to create complex links ICT 15
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
Example XML Document <? XML version="1. 0"? > <memo clearance-level = “ 0” status = “draft”> Start- and end-tags <memo-header> come in pairs <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
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
the content of compound elements: appears between start tag and end tag <? XML version="1. 0"? > <memo clearance-level = “ 0” status = “draft”> a compound element <memo-header> includes all of the complete <from>Brian Smith</from> subelements: the tags and <to>Mary Brown</to> content of the subelements <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
Attributes in XML In the document, we see: <memo clearance-level = “ 0” status = “draft”> tag name attribute name value Attributes are associated with elements…. and the assignment of values to attributes always appear in the start tag for the element. OGI DISC - modified and extended by SINTEF Slide
Namespaces Example Slightly modified listings document <? xml version="1. 0"> <Recent-Listings Area="Raleigh Hills" Date="March 97” Default xmlns=“http: //www. century 21. com/listings. dtd” Namespace xmlns: mls="urn: uuid: C 2 F 41010 -65 B 3 -11 d 1 -A 29 F 00 AA 00 C 14882" > <For-Sale> “Named” <Home id="h 1"> Namespace <Address>8225 SW Canyon Lane</Address> <mls: Structure> <Num-Beds>3</Num-Beds> Prefix <Num-Baths>2</Num-Baths>. . . OGI DISC - modified and extended by SINTEF Slide
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) ICT 22
XML Schema ICT 23
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. ICT 24
Simple types are defined by restricting a built-in-type or another simple type <simple. Type name=“age”> <restriction base=“integer”> <min. Inclusive value=“ 0”/> <max. Inclusive value=“ 130”/> </restriction> </simple. Type> fourteen facets to restrict including: pattern, enumeration, length(3), period and duration ICT 25
Another Example <simple. Type name="US-Flag-Colors"> <restriction base="string"> <enumeration value="red"/> <enumeration value="white"/> <enumeration value="blue"/> </restriction> </simple. Type> ICT 26
Defining complex types <xsd: complex. Type 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: complex. Type> <xsd: complex. Type name="Purchase. Order. Type"> <xsd: sequence> <xsd: element name="ship. To" type="Address" />. . . </xsd: complex. Type> ICT 27
Document instance of purchase order <Purchase. Order order. Date="1999 -05 -20"> name=“ship. To" < country="US"> ship. To <name>Alice Smith</name> <street>123 Maple Street</street> <city>Mill Valley</city> <state>CA</state> <zip>90952</zip> </ type="Address" ship. To> . . . </Purchase. Order> ICT 28
<complex. Type> or <simple. Type>? When do you use the complex. Type element and when do you use the simple. Type element? Use the complex. Type element when you want to define child elements and/or attributes of an element Use the simple. Type element when you want to create a new type that is a refinement of a built-in type (string, integer, etc) ICT 29
Defining attributes <attribute name="Category" use="required"> <simple. Type> Anonomous type <restriction base="string"> <enumeration value="autobiography"/> <enumeration value="non-fiction"/> <enumeration value="fiction"/> </restriction> </simple. Type> </attribute> • Note: attributes can only have simple. Types (i. e. , attributes cannot have child elements). ICT 30
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. "bar and boo are attributes of foo" <element name="foo"> <complex. Type> <sequence> … </sequence> <attribute name="bar" …/> <attribute name="boo" …/> </complex. Type> </element> ICT 31
Inheritance: Extending complex types <complex. Type name="USAddress"> <extension base="Address"> <sequence> <element name="zip" type="xsd: string"/> </sequence> </extension> </complex. Type> ICT 32
Elements <element name="zip” type="xsd: string"/> tag name in instance document type is either built-in types, simple. Types or complex. Types XML instance: <zip>90210</zip> ICT 33
XSD: XML text editor <xs: schema xmlns: xs="http: //www. w 3. org/2001/XMLSchema"> </xs: schema> Inside here goes: • elements • complex. Types • simple. Types 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. ICT 34
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. ICT 35
PIM 4 SOA main mappings to XSD PIM 4 SOA element XSD equivalent Document Schema Entity Complex. Type Association Element Attribute Simple. Type Notes 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 Attributes having simple types are mapped to Attributes in complex types. Attributes with complex types in the PIM 4 SOA model are mapped in the same way as Associations. If the Item. Type from the PIM 4 SOA model is not an entity (meaning it is a simple type) a Simple. Type definition is created in the schema. ICT 36
Web Service Description Language (WSDL) ICT 37
Making a SOAP function call over HTTP Request Header Body XML Data HTTP Response Header Body XML Data ICT 38
The SOAP Envelope <SOAP: Envelope> <SOAP: Header></SOAP: Header> Optional <SOAP: Body> <m: Function. Name> <param. Name 1>param. Value 1</param. Name 1> <param. Name 2>param. Value 2</param. Name 2> </m: Function. Name> </SOAP: Body> </SOAP: Envelope> ICT 39
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 W 3 C specification providing the foremost language for the description of Web service definitions. W 3 C, "Web Services Description Language (WSDL) Version 2. 0 Part 1: Core Language", World Wide Web Consortium (W 3 C), W 3 C Working Draft, 3 August 2004. http: //www. w 3. org/TR/2004/WD-wsdl 20 -20040803/ ICT 40
WSDL: Conceptual view Business Entities Web Service Interfaces (Syntactic) Web Service Interface Description WSDL ___________ ______ Messaging Encoding Raw XML SOAP “Binary” Bindings and Endpoint Descriptions eb. XML EDI Underlying Protocols HTTP/WEB SMTP/EMAIL FTP MQ-Series VANs ICT 41
WSDL: Conceptual model WS Interface WS Client Operations Invoked through Ports WS Provider Porttype Operations Ports Concrete Endpoint Address Operation Name, Abstract Message Parts Schema Message Exchange Pattern (Reusable) Binding Concrete Message Encoding Concrete Messaging Protocol ICT 42
WSDL: Message exchange patterns WS Client WS Provider Time Request-Response One-Way Solicit-Response Notification ICT 43
WSDL 1. 1 metamodel WSDL Component WSDL Document A container for data type definitions 0. . 1 Include + Location Import + Name. Space + Location A collection of related endpoints 0. . * 0. . 1 Element + Name + Target. Name. Space + Name 0. . * + Name An abstract, + Base. Type + typed definition. Min. Occurs + Max. Occurs of the data being communicated 1. . * Port 0. . * + Name 0. . 1 A concrete protocol and data format specification for a particular port type Part 0. . * Message 1 1 Binding + Target. Name. Space Definition Service A single endpoint defined as a combination of a binding and a network address Schema Types 0. . * Port Type + Name +fault 0. . 1 + Name + Type + Element +output +input + Name 1 1 An abstract set of operations supported by one or more endpoints 1. . * Operation + Name An abstract, description of an action supported by the service ICT 44
UML profile for WSDL UML representation Text representation ICT 45
Interf ace <types> <schema> <complex. Type name="Credit. Card">. . . <element name="number" type="string"/> <element name="expires" type="date"/>. . . s </types> s Cla <message name="validate. Request"> <part name="card" type="Credit. Card"/></message>. . . <port. Type name="Payment"> <operation name="validate"> <input message="validate. Request"/> <output message="validate. Response"/> Copy </operation></port. Type> -down Inher <port. Type name="Transaction. WFS"> itance <operation name="get. Capabilities">. . . <operation name="describe. Feature. Type">. . . <operation name="get. Feature">. . . <operation name="lock. Feature">. . . <operation name="transaction">. . . ce terfa <binding name="Payment. SOAPBinding" type="Payment"> In <soap: binding transport="http: //schemas. xmlsoap. org/soap/http". . . > <operation name="validate">. . . </binding> <binding name="Transaction. WFSSOAPBinding" type="Payment"> Rea <operation name="get. Capabilities">. . . lize <operation name="describe. Feature. Type">. . . <operation name="get. Feature">. . . <operation name="lock. Feature">. . . <operation name="transaction">. . . </binding> ice <service name="my. Web. Service"> usiness. Serv B <port name="Payment_Port” binding="Payment. SOAPBinding"> <soap: address location=”. . www. my. Web. Service. com"/>. . . <port name="Transaction. WFS_Port” binding="Transaction. WFSSOAPBinding">… ICT 46
Business Process Execution Language (BPEL) ICT 47
BPEL is a Web service composition language. It defines how to compose other Web services so to accomplish a more 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. ICT 48
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 ICT 49
BPEL: Simplified view A BPEL process is a composite Web service with a WSDL description. ICT 50
BPEL Foundations ICT 51
BPEL: Details • Two Uses – Executable process descriptions – Business protocol descriptions – Abstract processes • Partner links WSDL Port. Type Process 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 ICT 52
BPEL example PO : POMessage receive flow shipping. Info shipping. Schedule sequence reply Invoice : Inv. Message ICT 53
BPEL Process <process name="purchase. Order. Process" xmlns="http: //schemas. xmlsoap. org/ws/2003/03/business-process/"> <partner. Links> <partner. Link name="purchasing" partner. Link. Type="lns: purchasing. LT" my. Role="purchase. Service"/> <partner. Link name="invoicing" partner. Link. Type="lns: invoicing. LT" my. Role="invoice. Requester" partner. Role="invoice. Service"/> <partner. Link name="shipping" partner. Link. Type="lns: shipping. LT" my. Role="shipping. Requester" partner. Role="shipping. Service"/> <partner. Link name="scheduling" partner. Link. Type="lns: scheduling. LT" partner. Role="scheduling. Service"/> </partner. Links> ICT 54
BPEL process <sequence> <receive partner. Link="purchasing" port. Type="lns: purchase. Order. PT" operation="send. Purchase. Order" variable="PO"/> <flow> <links> <link name="ship-to-invoice"/> <link name="ship-to-scheduling"/> </links> <sequence> <assign> <copy> <from variable="PO" part="customer. Info"/> <to variable="shipping. Request" part="customer. Info"/> </copy> </assign>. . . ICT 55
BPEL process <invoke partner. Link="shipping" port. Type="lns: shipping. PT" operation="request. Shipping" input. Variable="shipping. Request" output. Variable="shipping. Info"> <source link. Name="ship-to-invoice"/> </invoke> <receive partner. Link="shipping" port. Type="lns: shipping. Callback. PT" operation="send. Schedule" variable="shipping. Schedule"> <source link. Name="ship-to-scheduling"/> </receive>. . . ICT 56
UML profile for BPEL ICT 57
PIM 4 SOA main mappings to BPEL PIM 4 SOA element BPEL equivalent Service. Provider 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. Empty This might be a task requiring further implementation or human interaction beyond the scope of the PIM 4 SOA. Task (ii) (no collaboration use) Notes 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 Collaboration. Use Role. Binding Partner. Link The Collaboration. Uses defined for the Service. Provider tell us what Partner. Links we will need. See Collaboration. Use. Path Partner. Link, Role(…) This defines a specific use of a Partner. Link, alongside what role we are playing, and even the Port. Type being used. See links to the WSDL transformation described below. All messages sent and received must have appropriate variables defined within the BPEL ICT 58
RSM and UML profile for Web services ICT 59
Referanser, neste forelesning. . . XML, XML Schema, WSDL: www. w 3 c. 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) ICT 60
60cf0ad3eaeaf926a9a0274a22f372d3.ppt