360 likes | 516 Views
BPEL: Business Process Execution Language for Web Services. Dr. Yuhong Yan NRC-IIT-Fredericton Internet logic. What is BPEL. It is positioned to become a standard for Web service composition . a notation for specifying business process behavior based on Web services.
E N D
BPEL: Business Process Execution Language for Web Services Dr. Yuhong Yan NRC-IIT-Fredericton Internet logic
What is BPEL • It is positioned to become a standard for Web service composition. • a notation for specifying business process behavior based on Web services. • a joint specification of IBM, BEA, Microsoft, SAP, and Siebel • OASIS ( Organization for the Advancement of Structured Information Standards e-business standards) standard.
The description of a workflow Need Process to satisfy need Need satisfied Make and serve Go to coffee shop Order Drink Satisfy thirst with coffee Thirst quenched Service Buy coffee machine Install Operate Fill cup Drink Tangible good + self service
The description of workflow Loan Request request.amount>=1000 request.amount <1000 Send to Risk Assessor Send to Approver risk.level!=low risk.level=low Prepare the answer Reply
BPEL: describe the business logic • The sequence of the activities (operations in WSDL) • The triggering conditions of the activities • The consequences of executing the activities • The partners for the external activities • The composition of Web Services • The binding to WSDL
A C B D E Business Process (what) versus WSDL (how) • Business Process: whatto do • Modeled as a sequence of activities • Tools aid to define, monitor, and manage business processes Business Process WSDL WSDL WSDL • WSDL: howto execute activities • An activity can be an internal or external Web service (SOAP/WSDL) • A business process can be exposed for consumption by a client app or another business process WSDL WSDL APPLICATION
BPEL Process Model Dynamic Partner/ Service Selection WSDL portType A Business Process: 1. Comprises choreography elements to define behavior 2. Exposes operations with constraints as Web services 3. Uses other Web services to do its job 1 A B 2 C D 3 E External Service Service logic
How BPEL looks like? <process name="echoString" targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"> <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:echoPLT" myRole="service"/> </partnerLinks> <variables> <variable name="request" messageType="tns:StringMessageType"/> </variables> <sequence name="EchoSequence"> <receivepartnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" createInstance="yes" name="EchoReceive"/> <reply partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" name="EchoReply"/> </sequence> </process>
How BPEL looks like? • <process>: root element of bpel • <partnerLink>: external partners • <variables>: variables in the process • <sequence>: a sequence scope • <receive>, <reply>: basic activities
BPEL basic activities • <receive> allows the business process to do a blocking wait for a matching message to arrive. • <reply> allows the business process to send a message in reply to a message that was received through a <receive>. The combination of a <receive> and a <reply> forms a request-response operation for the process. • <invoke> allows the business process to invoke a one-way or request-response operation on a portType offered by a partner.
BPEL basic activities (Cont’d) • <assign> is used to copy data from one place to another. • <throw> generates a fault from inside the business process. • <terminate>: terminate the entire service instance. It is only available in executable processes. • <wait> allows you to wait for a given time period or until a certain time has passed. • <empty> allows you to insert a “do nothing” instruction to the process.
<process name="echoString" targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"> <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:echoPLT" myRole="service"/> </partnerLinks> <variables> <variable name="request" messageType="tns:StringMessageType"/> </variables> <sequence name="EchoSequence"> <receivepartnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" createInstance="yes" name="EchoReceive"/> <reply partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" name="EchoReply"/> </sequence> </process> <definitions targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="StringMessageType"> <part name="echoString" type="xsd:string"/> </message> <portType name="echoPT"> <operation name="echo"> <input message="tns:StringMessageType"/> <output message="tns:StringMessageType"/> </operation> </portType> <plnk:partnerLinkType name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType> <!-- The service name and the TNS represent my service ID QName --> <service name="echoServiceBP"> </service> </definitions> Activities in BPEL vs.portType in WSDL
The structure of activities • <sequence>: an ordered sequence of steps • <switch>: “case-statement” approach • <while>: loop • <pick>: execute one of several alternative paths • <flow>: parallel steps
Partners • For <invoke> • Invoke an operation at an external web service • The external web service is Process partner • For <receive> and <reply> • The client sends message to invoke a local web service • The client is client partner • <partnerLinks> : The different parties involved in the business process
<partnerLinks> in BPEL <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:echoPLT" myRole="service"/> </partnerLinks> <partnerLinkType> in WSDL <plnk:partnerLinkType name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType>
<process name="echoString" targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"> <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:echoPLT" myRole="service"/> </partnerLinks> <variables> <variable name="request" messageType="tns:StringMessageType"/> </variables> <sequence name="EchoSequence"> <receivepartnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" createInstance="yes" name="EchoReceive"/> <reply partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" name="EchoReply"/> </sequence> </process> <definitions targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="StringMessageType"> <part name="echoString" type="xsd:string"/> </message> <portType name="echoPT"> <operation name="echo"> <input message="tns:StringMessageType"/> <output message="tns:StringMessageType"/> </operation> </portType> <plnk:partnerLinkType name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType> <!-- The service name and the TNS represent my service ID QName --> <service name="echoServiceBP"> </service> </definitions> PartnerLink in BPEL vs.partnerLinkType in WSDL
<variables> • Data variables used by activities • <variable messagetype=“...”>: WSDL message; • <variable type=“…”>: XML Schema simple type; • <variable element=“…”>: XML Schema element. • Variables associated with message types can be specified as input or output variables for invoke, receive and reply activities.
<process name="echoString" targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"> <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:echoPLT" myRole="service"/> </partnerLinks> <variables> <variable name="request" messageType="tns:StringMessageType"/> </variables> <sequence name="EchoSequence"> <receivepartnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" createInstance="yes" name="EchoReceive"/> <reply partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" name="EchoReply"/> </sequence> </process> <definitions targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="StringMessageType"> <part name="echoString" type="xsd:string"/> </message> <portType name="echoPT"> <operation name="echo"> <input message="tns:StringMessageType"/> <output message="tns:StringMessageType"/> </operation> </portType> <plnk:partnerLinkType name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType> <!-- The service name and the TNS represent my service ID QName --> <service name="echoServiceBP"> </service> </definitions> Variables in BPEL vs.Messages in WSDL
<faultHandlers> • In response to faults • Defines the recovery actions when faults occur • Its sole aim is to undo the partial and unsuccessful work of a scope in which a fault has occurred.
<process name="echoString" targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"> <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:echoPLT" myRole="service"/> </partnerLinks> <variables> <variable name="request" messageType="tns:StringMessageType"/> </variables> <sequence name="EchoSequence"> <receivepartnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" createInstance="yes" name="EchoReceive"/> <reply partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" name="EchoReply"/> </sequence> </process> <definitions targetNamespace="urn:echo:echoService" xmlns:tns="urn:echo:echoService" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="StringMessageType"> <part name="echoString" type="xsd:string"/> </message> <portType name="echoPT"> <operation name="echo"> <input message="tns:StringMessageType"/> <output message="tns:StringMessageType"/> </operation> </portType> <plnk:partnerLinkType name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType> <!-- The service name and the TNS represent my service ID QName --> <service name="echoServiceBP"> </service> </definitions> EachString: BPEL vs. WSDL
Echo Sample <PartnerLinks> in BEPL <partnerLinks> <partnerLink name="caller“ partnerLinkType="tns:echoPLT“ myRole="service"/> </partnerLinks> <partnerLinkType> in WSDL <plnk:partnerLinkType xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType>
Activities in BEPL <sequence name="EchoSequence"> <receive partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" createInstance="yes" name="EchoReceive"/> <reply partnerLink="caller" portType="tns:echoPT" operation="echo" variable="request" name="EchoReply"/> </sequence> PortType in WSDL <portType name="echoPT"> <operation name="echo"> <input message="tns:StringMessageType"/> <output message="tns:StringMessageType"/> </operation> </portType>
Simple sample <PartnerLinks> and <Partners> in BEPL <partnerLinks> <partnerLink name="caller" partnerLinkType="tns:StockQuotePLT"/> <partnerLink name="provider" partnerLinkType="tns-utils:StockQuotePLT"/> </partnerLinks> <partners> <partner name="invoker"> <partnerLink name="caller"/> </partner> <partner name="serviceProvider"> <partnerLink name="provider"/> </partner> </partners> another Web Service defined in stockquote.wsdl
Simple: StockQute Sample <variable name="request" messageType="tns:request"/> <variable name="response" messageType="tns:response"/> … <receive name="receive" partnerLink="caller" portType="tns:StockQuotePT" operation="gimmeQuote" variable="request" createInstance="yes"/> <reply name="reply" partnerLink="caller" portType="tns:StockQuotePT" operation="gimmeQuote" variable="response"/> Variable, Receive and Reply in BPEL <message name="request"> <part name="symbol" type="xsd:string"/> </message> <message name="response"> <part name="quote" type="xsd:float"/> </message> <portType name="StockQuotePT"> <operation name="gimmeQuote"> <input message="tns:request"/> <output message="tns:response"/> </operation> </portType> Message and portType in WSDL
Invoke external WSDL <Invoke> in BEPL <invoke name="invoke" partnerLink="provider" portType="sqp:StockQuotePT" operation="getQuote" inputVariable="invocationrequest" outputVariable="invocationresponse"/> PortType in external stockquote.wsdl <portType name="StockquotePT"> <operation name="getQuote"> <input message="tns:GetQuoteInput"/> <output message="tns:GetQuoteOutput"/> </operation> </portType>
LoanApproval Sample Import two external Web Services plus one external definition file in WSDL <import namespace="http://tempuri.org/services/loandefinitions" location="http://localhost:8080/bpws4j-samples/loanapproval/loandefinitions.wsdl"/> LoanApprover Web Service: <import namespace="http://tempuri.org/services/loanapprover" location="http://localhost:8080/bpws4j-samples/loanapproval/loanapprover.wsdl"/> LoanAssessor Web Service: <import namespace="http://tempuri.org/services/loanassessor" location="http://localhost:8080/bpws4j-samples/loanapproval/loanassessor.wsdl"/>
<PartnerLinkType> in WSDL <plnk:partnerLinkType xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" name="loanApprovalLinkType"> <plnk:role name="approver"> <plnk:portType name="apns:loanApprovalPT"/> </plnk:role> </plnk:partnerLinkType> portType in loanapprover.wsdl <portType name="loanApprovalPT"> <operation name="approve"> <input message="loandef:creditInformationMessage"/> <output message="tns:approvalMessage"/> <fault name="loanProcessFault" message="loandef:loanRequestErrorMessage"/> </operation> </portType>
<PartnerLinkType> in WSDL <plnk:partnerLinkType xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" name="riskAssessmentLinkType"> <plnk:role name="assessor"> <plnk:portType name="asns:riskAssessmentPT"/> </plnk:role> </plnk:partnerLinkType> portType in loanassessor.wsdl <portType name="riskAssessmentPT"> <operation name="check"> <input message="loandef:creditInformationMessage"/> <output message="tns:riskAssessmentMessage"/> <fault name="loanProcessFault" message="loandef:loanRequestErrorMessage"/> </operation> </portType>
Links defined for dependencies between the activities in BEPL <links> <link name="receive-to-assess"/> <link name="receive-to-approval"/> <link name="approval-to-reply"/> <link name="assess-to-setMessage"/> <link name="setMessage-to-reply"/> <link name="assess-to-approval"/> </links>
Receive in BEPL <receive name="receive1" partnerLink="customer" portType="apns:loanApprovalPT" operation="approve" variable="request" createInstance="yes"> <source linkName="receive-to-assess" transitionCondition="bpws:getVariableData('request', 'amount')<10000"/> <source linkName="receive-to-approval" transitionCondition="bpws:getVariableData('request', 'amount')>=10000"/> </receive> condition <link name="receive-to-assess"/> <link name="receive-to-approval"/> <portType name="loanApprovalPT"> <operation name="approve"> <input message="loandef:creditInformationMessage"/> <output message="tns:approvalMessage"/> <fault name="loanProcessFault" message="loandef:loanRequestErrorMessage"/> </operation> </portType> portType in loanapprover.wsdl
<Invoke> in BEPL <invoke name="invokeAssessor" partnerLink="assessor" portType="asns:riskAssessmentPT" operation="check" inputVariable="request" outputVariable="riskAssessment"> <target linkName="receive-to-assess"/> <source linkName="assess-to-setMessage" transitionCondition="bpws:getVariableData('riskAssessment', 'risk')='low'"/> <source linkName="assess-to-approval" transitionCondition="bpws:getVariableData('riskAssessment', 'risk')!='low'"/> </invoke> <link name="receive-to-assess"/> <link name="assess-to-setMessage"/> <link name="assess-to-approval"/> condition <portType name="riskAssessmentPT"> <operation name="check"> <input message="loandef:creditInformationMessage"/> <output message="tns:riskAssessmentMessage"/> <fault name="loanProcessFault" message="loandef:loanRequestErrorMessage"/> </operation> </portType> portType in loanassessor.wsdl
A Sample – LoanApproval.bepl • <process name="loanApprovalProcess" • targetNamespace="http://acme.com/loanprocessing" • suppressJoinFailure="yes" • xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" • xmlns:lns="http://loans.org/wsdl/loan-approval" • xmlns:loandef="http://tempuri.org/services/loandefinitions" • xmlns:asns="http://tempuri.org/services/loanassessor" • xmlns:apns="http://tempuri.org/services/loanapprover"> • <variables> • <variable name="request" • messageType="loandef:creditInformationMessage"/> • <variable name="riskAssessment" • messageType="asns:riskAssessmentMessage"/> • <variable name="approvalInfo" • messageType="apns:approvalMessage"/> • <variable name="error" • messageType="loandef:loanRequestErrorMessage"/> • </variables>
<partnerLinks> • <partnerLink name="customer" • partnerLinkType="lns:loanApprovalLinkType" • myRole="approver"/> • <partnerLink name="approver" • partnerLinkType="lns:loanApprovalLinkType" • partnerRole="approver"/> • <partnerLink name="assessor" • partnerLinkType="lns:riskAssessmentLinkType" • partnerRole="assessor"/> • </partnerLinks> • <faultHandlers> • <catch faultName="lns:loanProcessFault" • faultVariable="error"> • <reply partnerLink="customer" • portType="apns:loanApprovalPT" • operation="approve" • variable="error" • faultName="invalidRequest"/> • </catch> • </faultHandlers>
<flow> • <links> • <link name="receive-to-assess"/> • <link name="receive-to-approval"/> • <link name="approval-to-reply"/> • <link name="assess-to-setMessage"/> • <link name="setMessage-to-reply"/> • <link name="assess-to-approval"/> • </links> • <receive name="receive1" partnerLink="customer" • portType="apns:loanApprovalPT" • operation="approve" variable="request" • createInstance="yes"> • <source linkName="receive-to-assess" • transitionCondition="bpws:getVariableData('request', 'amount')<10000"/> • <source linkName="receive-to-approval" • transitionCondition="bpws:getVariableData('request', 'amount')>=10000"/> • </receive>
<invoke name="invokeAssessor" partnerLink="assessor" • portType="asns:riskAssessmentPT" • operation="check" • inputVariable="request" • outputVariable="riskAssessment"> • <target linkName="receive-to-assess"/> • <source linkName="assess-to-setMessage" • transitionCondition="bpws:getVariableData('riskAssessment', 'risk')='low'"/> • <source linkName="assess-to-approval" • transitionCondition="bpws:getVariableData('riskAssessment', 'risk')!='low'"/> • </invoke> • <assign name="assign"> • <target linkName="assess-to-setMessage"/> • <source linkName="setMessage-to-reply"/> • <copy> • <from expression="'yes'"/> • <to variable="approvalInfo" part="accept"/> • </copy> • </assign>
<invoke name="invokeapprover" • partnerLink="approver" portType="apns:loanApprovalPT" • operation="approve" • inputVariable="request" • outputVariable="approvalInfo"> • <target linkName="receive-to-approval"/> • <target linkName="assess-to-approval"/> • <source linkName="approval-to-reply" /> • </invoke> • <reply name="reply" partnerLink="customer" portType="apns:loanApprovalPT" • operation="approve" variable="approvalInfo"> • <target linkName="setMessage-to-reply"/> • <target linkName="approval-to-reply"/> • </reply> • </flow> • </process>