This documentation is for WSO2 Enterprise Integrator version 6.5.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
||
Skip to end of metadata
Go to start of metadata

Objective

This sample illustrates the usage of the <if/> construct in verifying a logical condition.

Introducing the IF Construct

<if>
   <condition>number($tmpVar)=number(2)</condition> 
      <assign name="assignError"> 
        <copy> 
           <from> 
              <literal>Worked</literal> 
           </from> 
           <to variable="myVar" part="TestPart"/> 
        </copy> 
      </assign> 
   <else> 
      <assign name="assignZut"> 
        <copy> 
           <from> 
              <literal>Failed</literal> 
           </from> 
           <to variable="myVar" part="TestPart"/> 
        </copy> 
      </assign> 
   </else> 
</if>

The <condition/> element inside <if/> is used to implement the logical condition. Normally, an XPath expression is used. <else/> is used to implement false case. In the above example, value of tmpVar variable is converted to a number and checked against number 2 as follows:

<condition>number($tmpVar)=number(2)</condition>

Based on the tmpVar value, "TestPart" element value in myVar variable will be "Worked" or "Failed".

Note

Apache ODE runtime has default support for http://www.w3.org/TR/xpath/ , where the number($var) is defined.

Deploying the Sample

WSO2 BPS provides a sample, which can be deployed and executed to understand the IF constructs discussed above. Follow the instructions below to deploy and trigger the process.

1. Log in into BPS server management console and select "Processes -> Add" under the "Main" menu.

2. Upload the <EI_HOME>/samples/business-process/bpel/IfCondition.zip directory.

3. In the "Deployed Processes" window, click the "Process ID" to access its "Process Information" window.

4. Under the "WSDL Details" widget, trigger the process using the "TryIt" link to create an instance of it.

  • No labels