BPEL: Business Process Execution Language for Web Services Dr. Yuhong Yan NRC-IIT-Fredericton...
-
Upload
maurice-gaines -
Category
Documents
-
view
216 -
download
0
description
Transcript of BPEL: Business Process Execution Language for Web Services Dr. Yuhong Yan NRC-IIT-Fredericton...
BPEL: Business Process Execution Language for Web Services
Dr. Yuhong YanNRC-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
Buy coffee machine Install Operate Fill cup Drink
Thirst quenched
Satisfy thirst with coffee
Go to coffee shopOrder
Make and serveDrink
Tangible good + self service
Service
Need Process to satisfy need Need satisfied
The description of workflowLoan Request
Send to Risk Assessor Send to Approver
Prepare the answer Reply
request.amount>=1000request.amount <1000
risk.level=lowrisk.level!=low
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
Business Process (what) versus WSDL (how)
Business Process: what to do• Modeled as a sequence of activities• Tools aid to define, monitor, and manage business processes
WSDL: how to 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
ABC
D
E
APPLICATION
BusinessProcessWSDL
WSDL
WSDL
WSDL
WSDL
BPEL Process Model
A Business Process:1. Comprises choreography
elements to define behavior2. Exposes operations with
constraints as Web services3. Uses other Web services to
do its job
1
2
3
A
D
BC
E
Service logic
External Service
Dynamic Partner/Service Selection
WSDL portType
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"> <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></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.
Activities in BPEL vs.portType in WSDL
<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"> <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></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>
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>
<plnk:partnerLinkType name="echoPLT"> <plnk:role name="service"> <plnk:portType name="tns:echoPT"/> </plnk:role> </plnk:partnerLinkType>
<partnerLinkType> in WSDL
PartnerLink in BPEL vs.partnerLinkType in WSDL
<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"> <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></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>
• 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.
Variables in BPEL vs.Messages in WSDL
<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"> <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></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>
<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.
EachString: BPEL vs. WSDL
<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"> <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></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>
Echo Sample
<partnerLinks> <partnerLink name="caller“ partnerLinkType="tns:echoPLT“ myRole="service"/> </partnerLinks>
<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>
<PartnerLinks> in BEPL
<partnerLinkType> in WSDL
<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>
Activities in BEPL
<portType name="echoPT"> <operation name="echo"> <input message="tns:StringMessageType"/> <output message="tns:StringMessageType"/> </operation> </portType>
PortType in WSDL
Simple sample
<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>
<PartnerLinks> and <Partners> in BEPL
another Web Service defined in
stockquote.wsdl
<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
Simple: StockQute Sample
Invoke external WSDL
<invoke name="invoke" partnerLink="provider" portType="sqp:StockQuotePT" operation="getQuote" inputVariable="invocationrequest" outputVariable="invocationresponse"/>
<Invoke> in BEPL
<portType name="StockquotePT"> <operation name="getQuote"> <input message="tns:GetQuoteInput"/> <output message="tns:GetQuoteOutput"/> </operation> </portType>
PortType in external stockquote.wsdl
LoanApproval Sample
<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"/>
Import two external Web Services plus one external definition file 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>
<PartnerLinkType> in WSDL
<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
<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>
<PartnerLinkType> in WSDL
<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
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 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>
<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
Receive in BEPL
<link name="receive-to-assess"/> <link name="receive-to-approval"/>
condition
<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>
<Invoke> in BEPL
<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
<link name="receive-to-assess"/><link name="assess-to-setMessage"/><link name="assess-to-approval"/>
condition
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>