Expressions

Expressions allow us to access parts of the variables. In the <assign> activities, we can use expressions to copy parts of variables or specific elements. We specify the expressions within the <from> and <to> elements. Expressions are written in the selected expression language; the default is XPath 1.0. The XPath language allows us to address XML in a similar way that we address files and folders in the filesystem. For detailed information on XPath, please refer to http://www.w3.org/TR/xpath/.

We access BPEL variables in XPath using the $ operator. This is particularly useful in the <copy> assignments, where we would like to access specific nested elements.

To write the copy assignment from the previous example with expression, we can use the $ operator to access the variable instead of the variable attribute. The code would look as follows:

<assign>
  <copy>
    <from>$BookstoreAResponse<from/>
    <to>$BookStoreWithLowestQuantity<to/>
  </copy>
</assign>

Copying variable parts

To learn how to copy variable parts, we will look at the three types of variables (variables can be of a messageType, element, or type). Let's first look at the messageType variables.

We can access variable parts from expressions using XPath in the following way:

$variableName.messagePart/ns:node/ns:node…

For example, if we would like to access the Title from the BookstoreARequest variable, we would need to write:

$BookstoreARequest.payload/ns2:Title

If the variable contains an XML element, then we would navigate through it using the variable name and node steps (without the part, because elements do not contain parts, whereas WSDL messages, on the other hand, do). The same holds true for variables using XML types.

We can access such variables from XPath in the following way:

$variableName/ns:node/ns:node…
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.242.62