460 likes | 642 Views
Service Composition. Contents. Service composition Purchase Order process overview Main concepts in BPEL Advanced concepts in BPEL. Web services. The goal of the Web Services effort is to achieve interoperability between applications by using Web standards. business-to-consumer
E N D
Contents • Service composition • Purchase Order process overview • Main concepts in BPEL • Advanced concepts in BPEL
Web services • The goal of the Web Services effort is to achieve interoperability between applications by using Web standards. • business-to-consumer • business-to-business • enterprise application integration • Building blocks • SOAP • WSDL • UDDI
Service composition • Systems integration requires more than the ability to conduct simple interactions by using standard protocols. • The full potential of Web Services as an integration platform will be achieved only when applications and business processes are able to integrate their complex interactions by using a standard process integration model.
Service composition Tourism Agent Hotel Airlines Car rental
Composition types Orchestration Choreography
Composition middleware Company B Company A Web service Web service Composite WS Company C Composition engine Web service WS middleware Company D Web service
Main elements of composition middleware • A composition model and language • A development environment • A run-time environment
BPEL • Business Process Execution Language • OASIS standard executable language for specifying actions within business processes with web services Developed using BPEL
BPEL BPEL specification defines • The different roles taking part in the messages exchanges with the process • The port types that must be supported by the different roles and by the process itself • The orchestration and the other different aspect • Correlation information, defining how messages can be routed to the correct composition instances
BPEL Tools&Engines • Apache ODE • AvtiveVOS • Open ESB • WSO2 • BizTalk Server • Oracle BPEL Process Manager
Example: Purchase Order (PO) Service receive purchase order concurrency sequencing initiate price calculation decide on shipper initiate production scheduling complete price calculation arrange logistics complete production scheduling synchronization invoice processing, reply
PO Service PO Service receive synchronous invocation POMesssage Body of PO Service customer operation sendPurchOr on interface purchOrIf InvMessage reply
PO Service Interface • <wsdl:definitions targetNamespace="http://manufacturing.org/wsdl/purchase" xmlns:sns="http://manufacturing.org/xsd/purchase" xmlns:pos="http://manufacturing.org/wsdl/purchase" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> … • </wsdl:definitions>
PO Service Interface <wsdl:messagename="POMessage"> <wsdl:partname="customerInfo" type="sns:customerInfoType" /> <wsdl:partname="purchaseOrder" type="sns:purchaseOrderType" /> </wsdl:message> <wsdl:messagename="InvMessage"> <wsdl:partname="IVC" type="sns:InvoiceType" /> </wsdl:message> <wsdl:messagename="orderFaultType"> <wsdl:partname="problemInfo" element=”sns:OrderFault" /> </wsdl:message> <wsdl:portType name="purchaseOrderPT"> <wsdl:operation name="sendPurchaseOrder"> <wsdl:input message="pos:POMessage" /> <wsdl:output message="pos:InvMessage" /> <wsdl:fault name="cannotCompleteOrder" message="pos:orderFaultType" /> </wsdl:operation> </wsdl:portType> interface exported by PO Service
Partner Link Type <partnerLinkType> describes the way two services interact: - names an interface that must be declared in each - associates <role> with each end of the interaction <plnk:partnerLinkTypename="purchasingLT"> <plnk:rolename="purchaseService" portType="pos:purchaseOrderPT" /> </plnk:partnerLinkType>
Partner Link Type <plnk:partnerLinkType name="invoicingLT"> <plnk:role name="invoiceService" portType="pos:computePricePT" /> <plnk:role name="invoiceRequester" portType="pos:invoiceCallbackPT" /> </plnk:partnerLinkType> description of a possible relationship between two services Invoice requester Invoice service invoiceCallbackPT computePricePT
Process Name Each BP is assigned a name in the <process> tag <process name="purchaseOrderProcess" targetNamespace="http://example.com/ws-bp/purchase" xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:lns="http://manufacturing.org/wsdl/purchase"> … • </process>
Partner Link <partnerLink> construct in BPEL names a process and associates it with a role in that link. • <partnerLinks> • <partnerLink name="purchasing" • partnerLinkType="lns:purchasingLT" myRole="purchaseService" /> • <!-- other partnerLink’s go here --> • </partnerLinks>
Linkage: Customer to PO Service <plnk:partnerLinkType name="purchasingLT"> <plnk:role name="purchaseService" portType="pos:purchaseOrderPT" /> </plnk:partnerLinkType> WSDL inter- face exported by PO Service partner specification in customer process <partnerLinkname=“linkToPurchase" partnerLinkType="lns:purchasingLT" partnerRole="purchaseService" /> partner specification in PO Service <partnerLink name="purchasingLink” partnerLinkType="lns:purchasingLT" myRole="purchaseService" />
Partners • In general: • A partnerLinkTypeis not specific to a particular BP; it is a global, bilateral (WSDL) description of the interaction between two BPs. • A partnerLink declaration (BPEL) describes how the local BP interacts with other BPs through a partnerLinkType. <partnerLinks> <partnerLink name="purchasing" partnerLinkType="lns:purchasingLT" myRole="purchaseService" /> <partnerLink name="shipping" partnerLinkType="lns:shippingLT" myRole="shippingRequester" partnerRole="shippingService" /> </partnerLinks>
State of a BPEL Process Variables <variables> <variable name="myVar1" messageType="myNS:myWSDLMessageDataType" /> <variable name="myVar1" element="myNS:myXMLElement" /> <variable name="myVar2" type="xsd:string" /> <variable name="myVar2" type="myNS:myComplexType" /> </variables>
Behavior of a BPEL Process Providing and Consuming Web Services Receive activity <receive name="ReceiveRequestFromPartner" createInstance="yes" partnerLink="ClientStartUpPLT" operation="StartProcess" ... /> Reply activity <reply name="ReplyResponseToPartner" partnerLink="ClientStartUpPLT" operation="StartProcess" ... /> Invoke activity <invoke name="RequestResponseInvoke" partnerLink="BusinessPartnerServiceLink" operation="RequestResponseOperation" inputVariable="Input" outputVariable="Output" />
Behavior of a BPEL Process Structuring the Process Logic Sequence activity <sequence name="InvertMessageOrder"> <receive name="receiveOrder" ... /> <invoke name="checkPayment" ... /> <invoke name="shippingService" ... /> <reply name="sendConfirmation" ... /> </sequence> Flow activity <flow ...> <invoke name="checkFlight" ... /> <invoke name="checkHotel" ... /> <invoke name="checkRentalCar" ... /> </flow>
Behavior of a BPEL Process If-else activity <if name="isOrderBiggerThan5000Dollars"> <condition> $order > 5000 </condition> <invoke name="calculateTenPercentDiscount" ... /> <elseif> <condition> $order > 2500 </condition> <invoke name="calculateFivePercentDiscount" ... /> </elseif> <else> <reply name="sendNoDiscountInformation" ... /> </else> </if>
Behavior of a BPEL Process Data Manipulation Assign activity <assign> <copy> <from variable="Input" part="operation1Parameter"> <query> creditCardInformation </query> </from> <to variable="CreditCardServiceInput" /> </copy> </assign>
PO Service (BPEL) <variables> <variable name="PO" messageType="lns:POMessage" /> <variable name="Invoice" messageType="lns:InvMessage" /> </variables> <sequence> <receive partnerLink="purchasing" portType="lns:purchaseOrderPT" operation="sendPurchaseOrder" variable="PO“> </receive> • <flow> … concurrent body ….</flow> <reply partnerLink="purchasing" portType="lns:purchaseOrderPT" operation="sendPurchaseOrder" variable="Invoice"> </reply> </sequence>
Interaction with Shipping Provider operation requestShipping on interface shippingPT decide on shipper (invoke) shippingRequestMessage shippingProvider shippingInfoMessage scheduleMessage arrange logisitics (receive) role = shippingService operation sendSchedule on port shippingCallbackPT role = shippingRequester
Handling Shipping <wsdl:portTypename="shippingCallbackPT"> <wsdl:operationname="sendSchedule"> <wsdl:inputmessage="pos:scheduleMessage" /> </wsdl:operation> </wsdl:portType> interface exported by PO Service <wsdl:portTypename="shippingPT"> <wsdl:operationname="requestShipping"> <wsdl:inputmessage="pos:shippingRequestMessage" /> <wsdl:outputmessage="pos:shippingInfoMessage" /> • </wsdl:operation> </wsdl:portType> interface imported from shipping service
Handling Shipping <plnk:partnerLinkType name="shippingLT"> <plnk:role name="shippingService“ portType="pos:shippingPT" /> <plnk:role name="shippingRequester“ portType="pos:shippingCallbackPT" /> </plnk:partnerLinkType> WSDL <partnerLinks> <partnerLink name="shipping" partnerLinkType="lns:shippingLT" myRole="shippingRequester" partnerRole="shippingService" /> </partnerLinks> BPEL
Handling Shipping <sequence> <assign> <copy> <from>$PO.customerInfo</from> <to>$shippingRequest.customerInfo</to> </copy> </assign> <invoke partnerLink="shipping" portType="lns:shippingPT" operation="requestShipping" inputVariable="shippingRequest" outputVariable="shippingInfo"> </invoke> <receive partnerLink="shipping" portType="lns:shippingCallbackPT" operation="sendSchedule" variable="shippingSchedule"> </receive> </sequence>
Links Production scheduling cannot be completed until logistics have been arranged Concurrent sequence activities in flow • data produced by arrange logistics is needed by complete production scheduling • data communicated through globally shared variable decide on shipper initiate production scheduling arrange logistics complete production scheduling link source target
Links • <flow> • <links> • <link name="ship-to-scheduling" /> • </links> • <sequence> • <assign> … </assign> • <receive partnerLink="shipping“ …> • <sources> • <source linkName="ship-to-scheduling”/> • </sources> • </receive> • </sequence> • <sequence> • <invoke partnerLink="scheduling“ …> • <targets> • <target linkName="ship-to-scheduling" /> • </targets> • </invoke> • </sequence> • </flow>
Links Transition condition • <source linkName="request-to-approve"> • <transitionCondition> • $creditVariable/value < 5000 • </transitionCondition> • </source> Join condition • <targets> • <joinCondition> • $approve-to-notify or $decline-to-notify • </joinCondition> • <target linkName="approve-to-notify" /> • <target linkName="decline-to-notify" /> • </targets>
<flow ...> • <links> • <link name="request-to-approve" /> • <link name="request-to-decline" /> • <link name="approve-to-notify" /> • <link name="decline-to-notify" /> • </links> • <receive name="ReceiveCreditRequest" • createInstance="yes" • partnerLink="creditRequestPLT" • operation="creditRequest" • variable="creditVariable"> • <sources> • <source linkName="request-to-approve"> • <transitionCondition> • $creditVariable/value < 5000 • </transitionCondition> • </source> • <source linkName="request-to-decline"> • <transitionCondition> • $creditVariable/value ≥ 5000 • </transitionCondition> • </source> • </sources> • </receive> <invoke name="approveCredit" ...> <source linkName="approve-to-notify" /> <targets> <target linkName="request-to-approve" /> </targets> </invoke> <invoke name="declineCredit" ...> <source linkName=“decline-to-notify" /> <targets> <target linkName="request-to-decline" /> </targets> </invoke> <reply name="notifyApplicant" ...> <targets> <joinCondition> $approve-to-notify or $decline-to-notify </joinCondition> <target linkName="approve-to-notify" /> <target linkName="decline-to-notify" /> </targets> </invoke> </reply> </flow>
Exception Handling <faultHandlers> <catch faultName="lns:cannotCompleteOrder" faultVariable="POFault" faultMessageType="lns:orderFaultType"> <reply partnerLink="purchasing" portType="lns:purchaseOrderPT" operation="sendPurchaseOrder" variable="POFault" faultName="cannotCompleteOrder" /> </catch> </faultHandlers>
Process Structure • A business process is a hierarchy of nested scope • Each scope may have • definitions of variables • partner links • message exchanges • correlation sets • handlers
Lifecycle of a Scope • Lifecycle of a scope begins with the following initializations • Initialize variables and partner links • Instantiate correlation sets • Install fault handlers, termination handler, and event handlers • A scope finishes its work either successfully or unsuccessfully • Normal completion • Internal fault • External termination
Scoped Fault Handling <scope> <faultHandlers> <catch faultName="xyz:anExpectedError">...</catch> <catchAll><!-- deal with other errors --> ... </catchAll> </faultHandlers> <sequence> <!-- do work --> </sequence> </scope>
Undoing Completed Work <scope name="S1"> <faultHandlers> <catchAll> <compensateScope target="S2" /> </catchAll> </faultHandlers> <sequence> <scope name="S2"> <compensationHandler> <!-- undo work --> </compensationHandler> <!-- do some work --> </scope> <!-- do more work --> <!-- a fault is thrown here; results of S2 must be undone --> </sequence> </scope>
Correlation Sets • A web service might be configured with multiple instances of a BP to concurrently handle (stateful) conversations with multiple clients. • A mechanism is needed to: • Route an arriving message that is part of a particular conversation to the correct BP instance • Messages of a particular conversation can be recognized by the fact that they will generally all carry some identifying value(s) (e.g., customerID and orderNum)
Correlation Sets • A correlation set is a set of properties whose value is shared by all messages in a particular conversation. • A correlation set identifies the BP instance <correlationSet name=“PurchaseOrder” properties=“cor:customerID cor:orderNum”/> aliased to items of information contained in the messages of a conversation
Correlation Sets <flow> <links> <link name="buyToSettle" /> <link name="sellToSettle" /> </links> <receive name="receiveBuyerInformation" createInstance="yes" ...> <sources> <source linkName="buyToSettle" /> </sources> <correlations> <correlation set="tradeID" initiate="join" /> </correlations> </receive> • <receive name="receiveSellerInformation" createInstance="yes" ...> • <sources> • <source linkName="sellToSettle" /> • </sources> • <correlations> • <correlation set="tradeID" initiate="join" /> • </correlations> • </receive> • <invoke name="settleTrade" ...> • <targets> • <joinCondition>$buyToSettle and • $sellToSettle</joinCondition> • <target linkName="buyToSettle" /> • <target linkName="sellToSettle" /> • </targets> • </invoke> • ... • </flow>
Summary • Service composition • Purchase Order process overview • Main concepts in BPEL • Advanced concepts in BPEL