Assigning Boolean values to the variables

We can identify the logical conditions with a Boolean value. You will learn how to use Boolean values in the variables in this recipe.

Getting ready

This recipe continues the discussion of the BPEL process Manipulate1_1 from the Using mathematical calculations in the variables recipe.

In the Manipulate1_1 BPEL process, we define the Boolean variable as follows:

<variable name = "expensive_item" type = "xsd:boolean"/>

With this variable, we will check if the item is expensive or not.

How to do it…

The following steps explain how to assign and change a Boolean value of a variable:

  1. Open the Manipulate1_1 BPEL process.
  2. Add the assign activity and name it Boolean.
  3. We first initialize the variable to the false value as follows:
    <copy>
      <from expression = "false()"/>
      <to variable = "expensive_item"/>
    </copy>
  4. We check if the item is expensive, by comparing the item price against the fixed amount criteria as follows:
    <copy>
      <from expression = "bpws:getVariableData('inputVariable', 'payload', '/client:process/client:priceVAT') > 1000"/>
      <to variable = "expensive_item"/>
    </copy>
  5. Save the changes to the BPEL process and deploy it to Oracle SOA Server. We initiate an instance of the BPEL process with the following request message:
    <inputVariable>
      <part name = "payload" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
        <ns1:process xmlns:ns1 = "http://xmlns.oracle.com/Variables/Global/Manipulate1_1">
          <ns1:input>Jurij</ns1:input>
          <ns1:item>454</ns1:item>
          <ns1:priceVAT>67755</ns1:priceVAT>
        </ns1:process>
      </part>
    </inputVariable>

Let's now check the Audit Trail. We search for the Boolean assign activity. The execution data shows that the variable expensive_item is initialized with the value false, and after the evaluation of the condition against the price and fixed amount criteria, it was set to true as follows:

<expensive_item xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:ns = "http://www.w3.org/2001/XMLSchema" xsi:type = "ns:boolean">false</expensive_item>
<expensive_item xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:ns = "http://www.w3.org/2001/XMLSchema" xsi:type = "ns:boolean">true</expensive_item>
..................Content has been hidden....................

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