How to Access Fields Within Element-Based and Message Type-Based Variables
In the following example, the ssn
field is copied from the CreditFlow
process's input message into the ssn
field of the credit rating service's input message.
<assign> <copy> <from variable="input" part="payload" query="/tns:CreditFlowRequest/tns:ssn"/> <to variable="crInput" part="payload" query="/tns:ssn"/> </copy> </assign>
The following example shows how the BPEL file defines message type-based variables involved in this assignment:
<variable name="input" messageType="tns:CreditFlowRequestMessage"/> <variable name="crInput" messageType="services:CreditRatingServiceRequestMessage"/>
The crInput
variable is used as an input message to a credit rating service. Its message type, CreditFlowRequestMessage
, is defined in the CreditFlowService.wsdl
file, as shown in the following example:
<message name="CreditFlowRequestMessage"> <part name="payload" element="tns:CreditFlowRequest"/> </message>
CreditFlowRequest
is defined with a field named ssn
. The message type CreditRatingServiceRequestMessage
is defined in the CreditRatingService.wsdl
file, as shown in the following example:
<message name="CreditRatingServiceRequestMessage"> <part name="payload" element="tns:ssn"/> </message>
The following example shows the BPEL 2.0 syntax for how the BPEL file defines message type-based variables involved in the assignment in the first assignment example. Note that /tns:CreditFlowRequest
is not required.
<copy> <from>$input.payload/tns:ssn</from> <to>$crInput.payload</to> </copy>
A BPEL process can also use element-based variables. The following example shows how to use element-based variables in BPEL 1.1. The autoloan
field is copied from the loan application process's input message into the customer
field of a web service's input message.
<assign> <copy> <from variable="input" part="payload" query="/tns:invalidLoanApplication/autoloan: application/autoloan:customer"/> <to variable="customer"/> </copy> </assign>
The following example shows how to use element-based variables in BPEL 2.0.
<assign> <copy> <from>$input.payload/autoloan:application/autoloan:customer</from> <to>$customer</to> </copy> </assign>
The following example shows how the BPEL file defines element-based variables involved in an assignment:
<variable name="customer" element="tns:customerProfile"/>