Let's now copy the BookstoreBResponse
variable to the BookStoreWithLowestQuantity
variable. Because the BookstoreBResponse
variable is of a different message type than the BookStoreWithLowestQuantity
variable, we cannot copy variables directly.
However, both message variables use the same XML element, namely BookDataResponse
as payload
. Therefore, we can copy the payloads of both variables:
<if>
activity and locate the elseifBookstoreBLowerOrEqual branch.AssignBookstoreB
assign.BookstoreBResponse
variable (by clicking on the plus sign in front of it). You also need to open the BookStoreWithLowestQuantity
variable. Then, you need to connect payload
from the left-hand side with payload
on the right-hand side of the dialog window:AssignBookStoreWithLowestQuantity
.We have added the assign activity to copy the payload
part of the BookstoreBResponse
variable to the payload
part of the BookStoreWithLowestQuantity
variable. This is possible because both payloads are of the same XML element from the same XML namespace. The following source code has been generated:
In addition to copying variable parts, we can also copy constant expressions and literals. The following example shows how to copy a constant string to the BookstoreLocationWithLowestStockQuantity
variable (which is of the type string
):
<assign> <copy> <from>string('BookstoreA')</from> <to variable="BookstoreLocationWithLowestStockQuantity"/> </copy> </assign>
We are not restricted to such simple expressions. We can use any valid XPath 1.0 expressions (or the expressions of the selected expression language).
Another way of expressing the preceding copy would be the following:
<assign> <copy> <from>'BookstoreA'</from> <to>$BookstoreLocationWithLowestStockQuantity<to/> </copy> </assign>
We can also do a copy to a specific node of the variable, such as:
<assign> <copy> <from>'BookstoreB'</from> <to>$outputVariable.payload/ client:SelectedBookstoreLocation<to/> </copy> </assign>
We can specify two optional attributes for the <copy>
activity:
keepSrcElementName
: This specifies whether the element name of the destination will be replaced by the element name of the source. The default is No
.ignoreMissingFromData
: This specifies whether the BPEL engine should ignore missing data in the <from>
part of the copy assignment (and not raise a fault). The default is No
.We can also specify an optional attribute for the <assign>
activity: