Business Process Execution Language Web Services BPEL Business
Business Process Execution Language Web Services: BPEL
Business Process Execution Language n n n Define business processes as coordinated sets of Web service interactions Define both abstract and executable processes Enable the creation of compositions of Web services Where it comes from: l Strong roots in traditional flow models l Concepts from structured programming languages l On top of WSDL and core XML specifications l Merges WSFL and XLANG concepts The OASIS WS BPEL Technical Committee is advancing the BPEL 4 WS Specification Web Services: BPEL 2
BPEL & WSDL Shipping Services port. Type Production Scheduling port. Type Receive Purchase Order Invoice Services port. Type Initiate Price Calculation Purchase Order port. Type Complete Price Calculation Decide On Shipper Arrange Logistics Initiate Production Scheduling Complete Production Scheduling Invoice Processing Web Services: BPEL 3
BPEL & WSDL Shipping Services port. Type Production Scheduling port. Type Receive Purchase Order Invoice Services port. Type Initiate Price Calculation Purchase Order port. Type Complete Price Calculation Decide On Shipper Arrange Logistics Initiate Production Scheduling operation message Complete Production Scheduling Invoice Processing Web Services: BPEL 4
BPEL & WSDL Shipping Services port. Type Production Scheduling port. Type Receive Purchase Order Invoice Services port. Type Initiate Price Calculation Purchase Order port. Type Complete Price Calculation Decide On Shipper Arrange Logistics <port. Type name=“scheduling. PT” <operation name=“request. Production. Scheduling”> <input message=“pos: POMessage”/> Invoice Processing </operation> <operation name=“send. Shipping. Schedule”> <input message=“pos: schedule. Message”/> </operation> </port. Type> Web Services: BPEL Initiate Production Scheduling operation message Complete Production Scheduling 5
Structure of a BPEL Process <process. . . > <partners>. . . </partners> <containers>. . . </containers> <correlation. Sets>. . . </correlation. Sets> <fault. Handlers>. . . </fault. Handlers> <compensation. Handlers>. . . </compensation. Handlers> n (activities)* n n n 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> Web Services: BPEL 6
BPEL and WSDL Partners Partner B Partner A WSDL A Process Web Services: BPEL 7
BPEL and WSDL Partners Partner B Partner A WSDL A Service Link Type Web Services: BPEL 8
Partner Links n Partner links are used to represent interactions between a service and each of the parties with which it interacts n Partner links define the messages and port types used in the interactions in both directions, along with role names Web Services: BPEL 9
Partner Definitions and Links n. A partner is accessed over a WS “channel”, defined by a service link type <partner name=“. . . ” service. Link. Type=“. . . ” partner. Role=“. . . ” my. Role=“. . . ”/> n. A SLT defines two roles and the port. Types that each role needs to support <service. Link. Type name=“. . . ”> <role name=“. . . "> <port. Type name=“. . . ” />* </role> <role name=“. . . ”> <port. Type name=“. . . ”/>* </role> </service. Link. Type> Web Services: BPEL 10
Partner Links “Invoicing” partner link “Purchasing” partner link “Scheduling” partner link <partner. Link name="scheduling" partner. Link. Type="lns: scheduling. LT" partner. Role="scheduling. Service"/> <plnk: partner. Link. Type name="scheduling. LT"> “Shipping” <plnk: role name="scheduling. Service"> partner link <plnk: port. Type name="pos: scheduling. PT"/> </plnk: role> </plnk: partner. Link. Type> Web Services: BPEL The port. Type used in the partner link 11
Traditional Flow Models Control links define execution flow as a directed acyclic graph Flow of data is explicitly modeled through data links Web Services: BPEL Activities represent units of processing Activities are mapped to application invocations or human actions 12
BPEL Data Model Globally scoped data variables typed as WSDL messages Assignment activities move data around Web Services: BPEL Activities input / output is kept in global variables <container name=“. . . ” message=“. . . ”/>* 13
BPEL Basic Activities n Invokes an operation on a partner <invoke partner=“. . . ” port. Type=“. . . ” operation=“. . . ” input. Container=“. . . ” output. Container=“. . . ”/> n Receives invocation from a partner <receive partner=“. . . ” port. Type=“. . . ” operation=“. . . ” container=“. . . ” [create. Instance=“. . . ”] /> n Sends a reply message in partner invocation <reply partner=“. . . ” port. Type=“. . . ” operation=“. . . ” container=“. . . ”/> n Data assignment between containers <assign> <copy> <from container=“. . . ”/> <to container=“. . . ”/> </copy>+ </assign> Web Services: BPEL 14
BPEL Composition of Web Services Process WSDL Component A Component B B’s WSDL A’s WSDL Service Link Type Web Services: BPEL 15
More Basic Activities n Detects processing error and switches into fault processing mode <throw fault. Name=“. . . ” fault. Container=“. . . ”/> n Pull the plug on this instance <terminate/> n Execution stops for a specified amount of time <wait for=“. . . ”? until=“. . . ”? /> n Do nothing; a convenience element <empty> Web Services: BPEL 16
BPEL Structured Activities <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. . . > defines a control dependency between a source activity and a target Web Services: BPEL 17
Nesting Structured Activities: Example <sequence> <receive. . . /> <flow> <sequence> <invoke. . . /> <while. . . > <assign>. . . </assign> </while> </sequence> <receive. . . /> <invoke. . . /> </sequence> </flow> <reply. . . /> </sequence> Web Services: BPEL Seq Flow Seq While 18
Asynchronous Interactions in BPEL can model many types of interactions: l Simple stateless interactions l Stateful, long running, asynchronous interactions n For the latter case, how to ensure that two (or more) messages are referring to the same “session” ? Web Services: BPEL 19
Message Correlation n Associating two or more messages with each other in an asynchronous environment n Done by associating contents in a given message with its correlating message n For example, in a purchase order/invoice scenario, the invoice may contain the corresponding purchase order number Purchase Order: <Purchase. Order> <Purchase. Order. Number> <Purchase. Order. Date>. . . . </Purchase. Order> Web Services: BPEL Invoice: <Invoice> <Invoice. Number> <Invoice. Date> <Purchase. Order. Number>. . . . </Invoice> common in both messages 20
Correlation Sets n What is a correlation set? l A set of business data fields that capture the state of the interaction (“correlating business data”), e. g. , a “purchase order number”, a “customer id”, etc. l Each set is initialized once l Its values do not change in the course of the interaction n CSs : the data used to maintain the state of the interaction (a “conversation”) n At the process end of the interaction, CSs allow incoming messages to reach the right process instance Web Services: BPEL 21
Defining Correlation Sets n. A CS is a named set of properties. Properties are defined as WSDL extensibility elements <correlation. Set name=“. . . ” properties=“. . . ”/> n. A property has a simple XSD type and a global name <bpws: property name=“. . . ” type=“. . . ” /> Web Services: BPEL 22
Properties n. A property is “mapped” to a field in a WSDL message type <bpws: property. Alias property. Name=“. . . ” message. Type=“. . . ” part=“. . . ” query=“. . . ” /> n The property can thus be found in the messages actually exchanged n Typically a property will be mapped to several different message types and carried on many interactions, across operations and port. Types Web Services: BPEL 23
Using Correlation n An input or output operation identifies which correlation sets apply to the messages received or sent <receive partner=“. . . ” operation=“. . . ” port. Type=“. . . ” container=“. . . ”> <correlations> <correlation set=“Purchase. Order” initiation=“yes”/> </correlations> </receive> That CS will be used to assure that the message is related to the appropriate stateful interaction n A CS is initialized once, in an interaction where the set appears with the “initiation” attribute set to “yes”. Its value may never be changed afterward n Web Services: BPEL 24
Example: Defining Correlation Sets n. A customer ID and order number represent a unique purchase order <correlation. Set name=“Purchase. Order” properties=“cor: customer. ID cor: order. Number”/> <correlation. Set name=“Invoice” properties=“cor: vendor. ID cor: invoice. Number”/> n. A vendor ID and invoice number represent a unique invoice Web Services: BPEL 25
Example: Using Correlation Sets n Declares invoice correlation between purchase order and <invoke partner. Link=“Buyer” port. Type=“SP: Buyer. PT” operation=“Async. Purchase. Response” input. Variable=“POResponse”> <correlations> <correlation set=“Purchase. Order” initiate=“no” pattern=“out”> <correlation set=“Invoice” initiate=“yes” pattern=“out”> </correlations> </invoke> Web Services: BPEL 26
BPEL Handlers and Scopes n A scope is a set of (basic or structured) activities Each scope can have two types of handlers associated: n Fault handlers Many can be attached, for different fault types n Compensation handler A single compensation handler per scope n Web Services: BPEL scope Fault Handler Compensation Handler 27
Scope and Fault Example A Fault B E C D Web Services: BPEL 28
How Handlers Work n. A fault handler defines alternate execution paths when a fault occurs within the scope n Typical scenario: Fault is thrown (retuned by invoke or explicitly by process) 2. Execution of scope is terminated 3. Appropriate fault handler located (with usual propagation semantics) 4. Main execution is compensated to “undo” business effects of unfinished work 1. n. A compensation handler is used to reverse the work performed by an already completed scope l A compensation handler can only be invoked by the fault handler or compensation handler of its immediate enclosing scope Web Services: BPEL 29
Partial Work Unavoidable n Business processes are often of long duration, which means that a business process may need to be cancelled after many transactions have been committed during its progress n Consider a situation in which a user cancels a purchase order: Revert back to original state Sub mit Pur cha se Ord er Pro cess Pur cha se Ord er Che ck Inv ent ory Ord er Fro m Sup plie r User Cancels! n In this situation, it is not possible to lock system resources (ex: database records) for extended periods of time l Therefore, the partial work must be undone as best as possible Web Services: BPEL 30
Compensation Handlers n Invoked to perform compensation activities — a “wrapper” for compensation activities: l. Specifies a compensating operation on a given port. Type for a given partner link: The Cancel. Purchase operation invokes a cancellation <compensation. Handler> <invoke partner. Link=“Seller” port. Type=“SP: Purchasing” operation=“Cancel. Purchase” input. Variable=“get. Response” output. Variable=“get. Confirmation”> <correlations> <correlation set=“Purchase. Order” pattern=“out”/> </correlations> </invoke> The response to the purchase request is </compensation. Handler> used as input Web Services: BPEL 31
Dynamic Service Selection and Invocation n The relevant information about a partner service can be set up as part of business process deployment l This is a more “static” approach n However, it is also possible to select and assign partner services dynamically n BPEL uses endpoint references defined in the WSAddressing specification for this capability http: //msdn. microsoft. com/ws/2003/03/ws-addressing <wsa: Endpoint. Reference xmlns: wsa=“. . . ”> <wsa: Address>http: //www. someendpoint. com</wsa: Address> <wsa: Port. Type>Purchase. Order. Port. Type</wsa: Port. Type> </wsa: Endpoint. Reference> Port. Type and Address assocation Web Services: BPEL 32
- Slides: 32