BPEL流程已经部署到本地BPS服务器,BPEL代码如下:
<bpel:process xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:ns2="http://sample.wso2.org" xmlns:aop="http://wso2.org/sample/bankingArtifacts" xmlns:ns1="http://hcc.wso2" xmlns:ns="http://wso2.org/banking" xmlns:tns="http://wso2.org/sample/banking" xmlns:ns0="http://ws.wso2.org/dataservice" xmlns:xsd="http://sample.wso2.org/xsd" xmlns:hcc="http://hcc.wso2/xsd" name="AccountOpeningProcess" targetNamespace="http://wso2.org/sample/banking" suppressJoinFailure="yes">
<!-- ================================================================= -->
<!-- PARTNERLINKS -->
<!-- List of services participating in this BPEL process -->
<!-- ================================================================= -->
<bpel:import namespace="http://sample.wso2.org" location="CardService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<bpel:import namespace="http://hcc.wso2" location="AccountDetailService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<bpel:import namespace="http://ws.wso2.org/dataservice" location="CustomerDS.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<bpel:import namespace="http://wso2.org/sample/bankingArtifacts" location="AccountOpeningProcessArtifacts.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<bpel:import namespace="http://wso2.org/banking" location="AccountOpeningProcessService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<bpel:partnerLinks>
<bpel:partnerLink name="AOPPL" partnerLinkType="aop:AOPPLT" myRole="openAccountRole"/>
<bpel:partnerLink name="CDSPL" partnerLinkType="aop:CDSPLT" partnerRole="customerDSRole"/>
<bpel:partnerLink name="ADSPL" partnerLinkType="aop:ADSPLT" partnerRole="accountRole"/>
<bpel:partnerLink name="CSPL" partnerLinkType="aop:CSPLT" partnerRole="cardRole"/>
</bpel:partnerLinks>
<!-- ================================================================= -->
<!-- VARIABLES -->
<!-- List of messages and XML documents used within this BPEL process -->
<!-- ================================================================= -->
<bpel:variables>
<bpel:variable name="AOPPLRequest" messageType="ns:CreateAccountRequest"/>
<bpel:variable name="AOPPLResponse" messageType="ns:CreateAccountResponse"/>
<bpel:variable name="CDSPLResponse" messageType="ns0:op1Response"/>
<bpel:variable name="CDSPLRequest" messageType="ns0:op1Request"/>
<bpel:variable name="ADSPLResponse" messageType="ns1:createAccountResponse"/>
<bpel:variable name="ADSPLRequest" messageType="ns1:createAccountRequest"/>
<bpel:variable name="CSPLResponse" messageType="ns2:issueCardResponse"/>
<bpel:variable name="CSPLRequest" messageType="ns2:issueCardRequest"/>
</bpel:variables>
<!-- ================================================================= -->
<!-- ORCHESTRATION LOGIC -->
<!-- Set of activities coordinating the flow of messages across the -->
<!-- services integrated within this business process -->
<!-- ================================================================= -->
<bpel:sequence>
<bpel:receive name="Receive" partnerLink="AOPPL" operation="CreateAccount" portType="ns:AccountOpeningProcessService" variable="AOPPLRequest" createInstance="yes"/>
<bpel:assign validate="no" name="InitCustomerDataserviceRequest">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">
<ns0:op1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:NID/>
<ns0:Name/>
</ns0:op1>
</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="CDSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns0:NID</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="AOPPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"> nid </bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="CDSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"> ns0:Name </bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="AOPPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">name</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="CDSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns0:Name</bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="Invoke-CustomerDataService" partnerLink="CDSPL" operation="op1" portType="ns0:CustomerDSPortType" inputVariable="CDSPLRequest" outputVariable="CDSPLResponse"/>
<bpel:assign validate="yes" name="InitAccountRequest">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">
<hcc:createAccount xmlns:hcc="http://hcc.wso2">
<hcc:customerId/>
<hcc:isNewCustomer/>
<hcc:accountType/>
</hcc:createAccount>
</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="ADSPLRequest"/>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="CDSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"> ns0:Entry[1]/ns0:Customer </bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="ADSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns1:customerId</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="CDSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns0:Entry[1]/ns0:Flag</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="ADSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns1:isNewCustomer</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="AOPPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">accountType</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="ADSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns1:accountType</bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="Invoke-AccountService" partnerLink="ADSPL" operation="createAccount" portType="ns1:AccountDetailServicePortType" inputVariable="ADSPLRequest" outputVariable="ADSPLResponse"/>
<bpel:if name="IfNewCustomer">
<bpel:condition expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">$CDSPLResponse.parameters/ns0:Entry[1]/ns0:Flag = 0</bpel:condition>
<bpel:sequence name="Sequence">
<bpel:assign validate="no" name="InitCardServiceRequest">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">
<sam:issueCard xmlns:sam="http://sample.wso2.org">
<sam:customerID>?</sam:customerID>
<sam:isExistingCustomer>?</sam:isExistingCustomer>
<sam:customerName>?</sam:customerName>
<sam:accountNo>?</sam:accountNo>
</sam:issueCard>
</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="CSPLRequest"/>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="CDSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns0:Entry[1]/ns0:Customer</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="CSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns2:customerID</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="CDSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns0:Entry[1]/ns0:Flag</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="CSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns2:isExistingCustomer</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="ADSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns1:return/hcc:accountNo</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="CSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns2:accountNo</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="AOPPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">name</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="CSPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns2:customerName</bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="Invoke-CardService" partnerLink="CSPL" operation="issueCard" portType="ns2:CardServicePortType" inputVariable="CSPLRequest" outputVariable="CSPLResponse"/>
<bpel:assign validate="no" name="InitResponse">
<bpel:copy>
<bpel:from part="parameters" variable="CSPLResponse"/>
<bpel:to part="parameters" variable="AOPPLResponse"/>
</bpel:copy>
</bpel:assign>
</bpel:sequence>
<bpel:else>
<bpel:sequence name="Sequence1">
<bpel:assign validate="no" name="InitResponse">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">
<issueCardResponse xmlns="http://sample.wso2.org">
<return>
<accountNo xmlns="http://sample.wso2.org/xsd"/>
<customerID xmlns="http://sample.wso2.org/xsd"/>
</return>
</issueCardResponse>
</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="AOPPLResponse"/>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="ADSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns1:return/hcc:accountNo</bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="AOPPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">ns2:return/xsd:accountNo</bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="CDSPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"> ns0:Entry[1]/ns0:Customer </bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="AOPPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"> ns2:return/xsd:customerID </bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
</bpel:sequence>
</bpel:else>
</bpel:if>
<bpel:reply name="Reply" partnerLink="AOPPL" operation="CreateAccount" portType="ns:AccountOpeningProcessService" variable="AOPPLResponse"/>
</bpel:sequence>
</bpel:process>
当我点击 BPEL 面板上的“try it”按钮时,我得到以下用于 SOAP 消息传递的界面。在这种情况下,我将值设置为 1 和 PIS。
<body>
<p:CreateAccount xmlns:p="http://wso2.org/banking">
<!--Exactly 1 occurrence-->
<nid>"1"</nid>
<!--Exactly 1 occurrence-->
<name>"PIS"</name>
<!--Exactly 1 occurrence-->
<accountType>?</accountType>
</p:CreateAccount>
</body>
这种情况下的响应如下:
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soapenv:Server</faultcode>
<faultstring xmlns:axis2ns6="http://docs.oasis-open.org/wsbpel/2.0/process/executable">axis2ns6:selectionFailure</faultstring>
<detail/>
</soapenv:Fault>
服务器的堆栈跟踪如下:
TID: [0] [BPS] [2013-10-28 01:35:22,647] WARN {org.apache.ode.bpel.engine.BpelProcess} - Instance 3105 of {http://wso2.org/sample/banking}AccountOpeningProcess-9 has completed with fault: FaultData: [faultName={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure, faulType=null ({http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: No results for expression: 'ns0:NID' against '<?xml version="1.0" encoding="UTF-8"?>
<op1 xmlns="http://ws.wso2.org/dataservice"/>')] @49 {org.apache.ode.bpel.engine.BpelProcess}
TID: [0] [BPS] [2013-10-28 01:35:29,143] INFO {org.apache.ode.bpel.runtime.ASSIGN} - Assignment Fault: {http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure,lineNo=49,faultExplanation={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: No results for expression: 'ns0:NID' against '<?xml version="1.0" encoding="UTF-8"?>
<op1 xmlns="http://ws.wso2.org/dataservice"/>' {org.apache.ode.bpel.runtime.ASSIGN}
TID: [0] [BPS] [2013-10-28 01:35:29,143] INFO {org.apache.ode.bpel.runtime.ASSIGN} - Assignment Fault: {http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure,lineNo=49,faultExplanation={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: No results for expression: 'ns0:NID' against '<?xml version="1.0" encoding="UTF-8"?>
<op1 xmlns="http://ws.wso2.org/dataservice"/>' {org.apache.ode.bpel.runtime.ASSIGN}
TID: [0] [BPS] [2013-10-28 01:35:29,149] WARN {org.apache.ode.bpel.engine.BpelProcess} - Instance 3106 of {http://wso2.org/sample/banking}AccountOpeningProcess-9 has completed with fault: FaultData: [faultName={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure, faulType=null ({http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: No results for expression: 'ns0:NID' against '<?xml version="1.0" encoding="UTF-8"?>
<op1 xmlns="http://ws.wso2.org/dataservice"/>')] @49 {org.apache.ode.bpel.engine.BpelProcess}
TID: [0] [BPS] [2013-10-28 01:35:29,149] WARN {org.apache.ode.bpel.engine.BpelProcess} - Instance 3106 of {http://wso2.org/sample/banking}AccountOpeningProcess-9 has completed with fault: FaultData: [faultName={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure, faulType=null ({http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: No results for expression: 'ns0:NID' against '<?xml version="1.0" encoding="UTF-8"?>
<op1 xmlns="http://ws.wso2.org/dataservice"/>')] @49 {org.apache.ode.bpel.engine.BpelProcess}