Use Activebpel to orchestrate and control Web Services (2)

Source: Internet
Author: User
The first is to check the amount of credit card applications. If it exceeds $10,000, we will transfer the input data to the approver Web service for a response. Conversely, if the number is below $10,000, we call the Assessor Web service first, let it return an answer, if the response is "Lowrisk", then the application is immediately confirmed. Otherwise, we need to call the approver Web service further.

This is a straightforward business process that clearly demonstrates the power of BPEL and achieves the purpose of orchestrating different invocation scenarios for our core Web services. Now, let's take a look at the actual bpel-xml syntax.

<?xml version= "1.0" encoding= "UTF-8"?>
<process name= "loanapprovalprocess" suppressjoinfailure= "yes"
Targetnamespace= "Http://acme.com/loanprocessing"
Xmlns= "http://schemas.xmlsoap.org/ws/2003/03/business-process/"
Xmlns:apns= "Http://tempuri.org/services/loanapprover"
Xmlns:asns= "Http://tempuri.org/services/loanassessor"
Xmlns:bpws= "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:xsd= "Http://www.w3.org/2001/XMLSchema" >
<partnerLinks>
<partnerlink myrole= "Approver" name= "Customer" partnerlinktype= "Lns:loanapprovallinktype"/>
<partnerlink name= "Approver" partnerlinktype= "Lns:loanapprovallinktype" partnerrole= "approver"/>
<partnerlink name= "Assessor" partnerlinktype= "Lns:riskassessmentlinktype" partnerrole= "Assessor"/>
</partnerLinks>
<variables>
<variable messagetype= "Loandef:creditinformationmessage" name= "Request"/>
<variable messagetype= "Asns:riskassessmentmessage" name= "Riskassessment"/>
<variable messagetype= "Apns:approvalmessage" name= "Approvalinfo"/>
<variable messagetype= "loandef:loanrequesterrormessage" name= "error"/>
</variables>
<faultHandlers>
<catch faultname= "Apns:loanprocessfault" faultvariable= "Error" >
<reply faultname= "Apns:loanprocessfault" operation= "approve" partnerlink= "customer"
Porttype= "Apns:loanapprovalpt" variable= "error"/>
</catch>
</faultHandlers>
<flow>
<links>
<link name= "Receive-to-approval"/>
<link name= "Receive-to-assess"/>
<link name= "Approval-to-reply"/>
<link name= "Assess-to-setmessage"/>
<link name= "Assess-to-approval"/>
<link name= "Setmessage-to-reply"/>
</links>
<receive createinstance= "yes" name= "receive1" operation= "approve" partnerlink= "customer"
Porttype= "Apns:loanapprovalpt" variable= "Request" >
<source linkname= "Receive-to-approval" transitioncondition= bpws:getvariabledata (' request '),
' Amount ') >=10000 "/>
<source linkname= "receive-to-assess" transitioncondition= bpws:getvariabledata (' request '),
' Amount ') <10000 "/>
</receive>
<invoke inputvariable= "Request" Name= "Invokeapprover" operation= "approve"
Outputvariable= "Approvalinfo" partnerlink= "approver"
Porttype= "Apns:loanapprovalpt" >
<target linkname= "Receive-to-approval"/>
<target linkname= "Assess-to-approval"/>
<source linkname= "Approval-to-reply"/>
</invoke>
<invoke inputvariable= "Request" Name= "Invokeassessor" operation= "Check" outputvariable= "Riskassessment"
partnerlink= "Assessor"
Porttype= "ASNS:RISKASSESSMENTPT" >
<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>
<reply name= "Reply" operation= "approve" partnerlink= "Customer" porttype= "Apns:loanapprovalpt"
variable= "Approvalinfo" >
<target linkname= "Approval-to-reply"/>
<target linkname= "Setmessage-to-reply"/>
</reply>
<assign name= "Assign" >
<target linkname= "Assess-to-setmessage"/>
<source linkname= "Setmessage-to-reply"/>
<copy>
<from expression= "' Approved '"/>
<to part= "Accept" variable= "Approvalinfo"/>
</copy>
</assign>
</flow>
</process>

Note that the elements of BPEL are <partnerlink>, <variable>, <faulthandler>, <flow>, >target> etc. Continuing to explain the meaning of the BPEL syntax is beyond the scope of this question, but if you follow up you can see the same pattern in pseudocode. Also note that many BPEL processes are created using a special editor to avoid errors in handwriting XML.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.