Question

Is it possible to initialize BPEL variables at the declaration ? if so how ?

declaration example :

<variables>
    <variable name="offer" type="xsd:float"/>
    <variable name="response" type="xsd:string"/>
</variables> 
Was it helpful?

Solution

This is possible. BPEL 2.0 allows a from-spec directly in the variable declaration. However, this feature is not implemented by all BPEL engines, e.g. Apache ODE cannot handle such inline initializations.

The following snippet is valid BPEL 2.0:

<variables>
    <variable name="response" type="xsd:string">
        <from>'TocToc'</from>
    </variable>
    <variable name="offer" type="xsd:float">
        <from>100</from>
    </variable>
</variables>

For an example, please see page 121 in [1] and section 8.1 (page 45) of [1] for the definition.

[1] http://docs.oasis-open.org/wsbpel/2.0/wsbpel-v2.0.pdf

OTHER TIPS

We use Oracle BPEL and it allows properties to be set in the bpel.xml file like such:

 <preferences>
    <property name="output_file" encryption="plaintext">logging.txt</property>
    <property name="expire_hours" encryption="plaintext">10</property>
    <property name="retry_count" encryption="plaintext">4</property>
 </preferences>

The can be accessed in the code using ora:getPreference("varname")

These also show up on the BPEL console and can be changed by an admin if necessary.

After some googling, reading spec and examples ... I think it's not possible to initialize BPEL variables at the declaration ... If we want we need to do it in the process sequence :

...
    <variables>
        <variable name="response" type="xsd:string"/>
        <variable name="offer" type="xsd:float"/>
    </variables>
...
    <sequence>
        <receive createInstance="yes" .../>
...
        <assign name="init">
            <copy>
                <from>100</from>
                <to variable="offer"/>
            </copy>
            <copy>
                <from>'TocToc'</from>
                <to variable="response"/>
            </copy>
        </assign>
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top