<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Facilitating Rich Data Manipulation in BPEL using E4X</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Tammo van Lessen</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jo¨ rg Nitzsche</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Dimka Karastoyanova</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Architecture of Application Systems University of Stuttgart Universitaetsstrasse 38</institution>
          ,
          <addr-line>70569 Stuttgart</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The Business Process Execution Language (BPEL) uses XML to specify the data used within a process and realizes data flow via (globally) shared variables. Additionally, assign activities can be used to copy (parts of) variables to other variables using techniques like XPath or XSLT. Although BPEL's built-in functionality is sufficient for simple data manipulation tasks, it becomes very cumbersome when dealing with more sophisticated data models, such as arrays. ECMAScript for XML (E4X) extends JavaScript with support for XML-based data manipulation by introducing new XPath-like language features. In this paper we show how E4X can help to significantly ease data manipulation tasks and propose a BPEL extension that allows employing JavaScript/E4X for implementing them. As E4X allows defining custom functions in terms of scripts, reusability with respect to data manipulation is improved. To verify the conceptual framework we present a proof-of-concept implementation based on Apache ODE.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Business Process Management (BPM) and the workflow technology [
        <xref ref-type="bibr" rid="ref1 ref2">1,2</xref>
        ] in particular
have enjoyed a great success and have a heavy impact on industry and research. The
separation of business process logic and implementation of business functions enables
programming on a higher, i.e. business process-oriented level [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], and renders the
workflows flexible. Currently, the language for executable business processes is the
Business Process Execution Language (BPEL) [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] which is standardized by OASIS1.
BPEL is XML based and is a part of the Web Service standard stack [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. It uses XML as
data model and specifies activity implementations using the Web Service Description
Language (WSDL) [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        Data flow in BPEL is not explicitly specified but can be realized using (globally)
shared variables. Assign activities can be used to copy (parts of) variables to other
variables using XML data processing techniques. Although arbitrary expression languages
(e.g. XPath [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and XSLT [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]) can be used to specify expressions to select and copy
data, specifying the data manipulation is still a cumbersome task. For instance, it is not
possible with the conventional use of BPEL to add elements into a node set (i.e. array
operations) or to modify a certain value of a filtered node set.
      </p>
    </sec>
    <sec id="sec-2">
      <title>1 http://www.oasis-open.org/</title>
      <p>
        ECMAScript for XML (E4X) [
        <xref ref-type="bibr" rid="ref10 ref9">9,10</xref>
        ] extends JavaScript with support for
XMLbased data manipulation by introducing new XPath-like language features. The resulting
language provides convinient access to XML data and intuitive scripting primitives
with direct support for e.g. array operations. In this paper we use this extension to
improve BPEL with respect to its data manipulation capabilities and therefore we
propose an extension to WS-BPEL 2.0 to allow defining variable assignments in terms
of JavaScript/E4X expressions. For this we employ the extensibility features of BPEL,
in particular, &lt;extensionActivity&gt; and &lt;extensionAssignOperation&gt;.
This approach contributes a significant enhancement to data manipulation.
      </p>
      <p>The paper is structured as follows. Section 2 provides background information about
ECMAScript for XML. Subsequently, The BPEL extensions for E4X are presented in
Section 3 and are explained by example in Section 4. Section 5 presents a
proof-ofconcept implementation based on Apache ODE. Finally, Section 6 discusses related
work and Section 7 concludes the paper.
2</p>
      <sec id="sec-2-1">
        <title>ECMAScript for XML (E4X)</title>
        <p>ECMAScript for XML (E4X) is a language extension that adds native support for XML
to the ECMAScript family [11] (including JavaScript, ActionScript, JScript etc.). Unlike
other programming languages (like Java) that allow accessing XML data either as event
stream or in terms of the W3C DOM object model, E4X allows processing of XML data
directly on the language level. The XML tree can be navigated using an object-like “dot”
notation and allows for addressing XML child elements, attributes and node sets. Node
sets can be filtered using parentheses. The example in Listing 1 illustrates how an E4X
object is created and how subsequently the values of the quantity attribute for all items
with the name “SOA book” are retrieved. The example also shows how E4X can be used
in for loops to sum up the prices of all items in the example shopping cart.
var items = &lt;items&gt;
&lt;item name="SOA book" price="40" quantity="2"/&gt;
&lt;item name="BPM book" price="35" quantity="3"/&gt;
&lt;item name="EAI book" price="30" quantity="1"/&gt;
&lt;/items&gt;;
for each( var thisPrice in items..@price ) {</p>
        <p>sum += thisPrice;
}</p>
        <p>Listing 1. E4X sample code</p>
        <p>E4X allows assigning data values not only to single XML nodes but also to node
sets. This enables batch-like modifications of multiple nodes with a single assignment
expression (see [12] for further details about E4X).
BPEL 2.0 introduces effective extensibility mechanisms that allow for defining new
activity types (extension activities) as well as using different mechanisms for data
manipulation (extension assign operations). Since E4X provides powerful language
extensions to directly address and modify XML data, it makes a good candidate for
significantly improving BPEL’s data manipulation capabilities. The E4X extension for
BPEL is defined in terms of an extension namespace and an extension element for
both &lt;extensionAssignOperation&gt; and &lt;extensionActivity&gt; elements.
The extension namespace2 must be declared as a mustUnderstand extension in the
preamble of the BPEL process model to ensure that BPEL engines can understand and
execute E4X expressions. Subsequently, the &lt;js:snippet&gt; element can be used
within assign and extension activities respectively and can contain arbitrary JavaScript
code.</p>
        <p>The E4X extension for BPEL comprises two main parts. First, it makes sure that all
visible BPEL variables are injected into the JavaScript context so that they can be treated
as normal E4X variables within the JavaScript code snippet. Second, it defines a number
of functions that are necessary to glue both worlds together. These functions are listed in
Table 1.</p>
        <p>load(string...)
print(string...)
validate(BPELvariable)
throwFault(...)
processName()
activityName()
piid()</p>
        <p>Allows importing reusable JavaScript libraries. That
way, code snippets can be reused across JS/E4X
extended activities.</p>
        <p>Allows printing debug messages to the underlying
engine’s logging console.</p>
        <p>Makes sure that the given XML object complies with
the variable declaration.</p>
        <p>Creates a BPEL fault with a given QName and fault
message.</p>
        <p>Returns the name of the process model that is currently
being executed.</p>
        <p>Returns the name of the activity that executes the
JavaScript snipped that is currently being executed.</p>
        <p>Returns the name of the activity that executes the</p>
        <p>JavaScript snipped that is currently being executed.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>2 http://ode.apache.org/extensions/js</title>
      <sec id="sec-3-1">
        <title>Example</title>
        <p>As identified in Section 1 the most burdensome tasks are the (recurring) initialisation
of variables and dealing with arrays (which always requires the use of external XSL
scripts). In Listing 2 we demonstrate how E4X extension assign operations are utilized
in BPEL. The first operation makes use of the string concatenation operator += and
realises a typical Hello World! example. The second operation addresses the problems
mentioned above. First, it loads an external, reusable JavaScript library, which contains
helper methods to create and manipulate XML structures for our shopping cart example.
Instead of manually assigning an XML skeleton to a BPEL variable and setting several
values later on using XPath expressions, we can (re)use a shared method to create an
empty shopping cart. In the last line we use a different JavaScript method to transform
the values of the BPEL variable item, which was received from an external service,
into the XML format prescribed by the shopping cart structure. Subsequently it is added
to the virtual shopping cart (+= is the add operator on a node set).
&lt;assign name="e4x-assign"&gt;
&lt;extensionAssignOperation&gt;
&lt;js:snippet xmlns:js="http://ode.apache.org/extensions/js"&gt;</p>
        <p>myVar.TestPart += ’ World’;
&lt;/js:snippet&gt;
&lt;/extensionAssignOperation&gt;
&lt;extensionAssignOperation&gt;
&lt;js:snippet xmlns:js="http://ode.apache.org/extensions/js"&gt;
load(’shoppingCartUtils.js’);
shoppingCart.parameters = createShoppingCartSkeleton();
shoppingCart.parameters.items += createCartItem(item);
&lt;/js:snippet&gt;
&lt;/extensionAssignOperation&gt;
&lt;/assign&gt;</p>
        <p>Listing 2. JavaScript/E4X as extension assign operation implementation
Listing 3 demonstrates how to use JavaScript/E4X as extension activity
implementation. We assume that the shopping cart has been transformed into a purchase order
structure. Depending on the customer type (gold, silver, besteffort), we want to apply
different discount ratios. After checking whether the ratios are within a reasonable range,
the selected ratio is applied to all items, again by assigning values to a node set. In
addition we set the shipping mode to a non-priority mode for best-effort customers.</p>
      </sec>
      <sec id="sec-3-2">
        <title>5 Implementation</title>
        <p>The concepts proposed above have been implemented as an extension to Apache ODE3
and will be part of the upcoming ODE 2.0 release. It was originally intended to be a
proofof-concept implementation for the also newly introduced implementation of BPEL’s
3 http://ode.apache.org
&lt;extensionActivity name="calculateDiscount"&gt;
&lt;js:snippet xmlns:js="http://ode.apache.org/extensions/js"&gt;
if (goldRatio &gt; 1.0 || silverRatio &gt; 1.0) {
throwFault(’urn:myprocess’, ’IllegalArgumentFault’,</p>
        <p>’discount ratios must be &lt;= 1.0’);
}
if (customer.type == ’gold’) {</p>
        <p>po.items.item.price *= goldRatio;
} else if (customer.type == ’silver’) {</p>
        <p>po.items.item.price *= silverRatio;
} else if (customer.type == ’besteffort’) {</p>
        <p>po.shippingMode = ’snailmail’
}
&lt;/js:snippet&gt;
&lt;/extensionActivity&gt;</p>
        <p>Listing 3. JavaScript/E4X as extension activity implementation
extensibility mechanisms in ODE. It provides an extension operation implementation
which integrates Apache ODE with Mozilla’s Rhino4 as the underlying JavaScript/E4X
engine. Since the internal XML model of Rhino is not compatible with W3C’s DOM
model used by Apache ODE, it was necessary to implement a variable bridge that
facilitates overlaying BPEL variables in the JavaScript context. This has been implemented
in terms of a Rhino Delegator. The built-in functions are realized by overriding
Rhino’s ImporterTopLevel. The source code is available in Apache’s Subversion
repository5.</p>
      </sec>
      <sec id="sec-3-3">
        <title>6 Related Work</title>
        <p>BPELJ [13] is an extension to BPEL that enables the use of Java code within BPEL
activities. While the focus of BPELJ and the approach presented here is similar, BPELJ
does not comply with the extensibility features of BPEL 2.0 yet. Furthermore, selecting
an XML node in a DOM representation is still cumbersome since Java does not enable
selecting XML nodes directly. Hence E4X for BPEL becomes a valuable extension that
addresses this deficiency.</p>
        <p>[14] proposes an extension to BPEL enabling data manipulation based on ontological
knowledge. Using the semantics of data used in a process allows abstracting away
the actual implementation of the data manipulation task. It is sufficient to describe
which ontology concepts will be provided as input and what is expected as output to
discover appropriate data mediators using ontology reasoning. Abstracting away the
actual implementation of the data manipulation in processes completely frees process
modellers from defining data transformation in a process model and increases reusability
of data manipulation tasks. The downside of this approach is that performance decreases
4 http://www.mozilla.org/rhino/</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>5 http://svn.eu.apache.org/repos/asf/ode/trunk/extensions/e4x</title>
      <p>because appropriate transformation/mediation implementations have to be discovered
every time data has to be copied from one variable to another. Using the custom E4X
functions however, enables defining highly performant and reusable data manipulation
functionality.
7</p>
      <sec id="sec-4-1">
        <title>Conclusion</title>
        <p>Data manipulation in BPEL is based on XML data processing which makes it a
cumbersome task. In this paper we have proposed a BPEL extension that allows employing
Javascript/E4X for data manipulation tasks in BPEL and we have shown how E4X can
help to significantly ease their implementation. Moreover, reusability with respect to data
manipulation is improved as E4X allows defining custom functions in terms of scripts. To
verify the conceptual framework we have presented a proof-of-concept implementation
based on Apache ODE.</p>
      </sec>
      <sec id="sec-4-2">
        <title>Acknowledgements</title>
        <p>The work published in this article was partially funded by the SUPER project6 under the
EU 6th Framework Programme Information Society Technologies Objective (contract
no. FP6-026850).</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>6 http://www.ip-super.org/</title>
      <p>11. Ecma International: ECMAScript Language Specification. Standard ECMA-262 (December
1999)
12. Tynjala, J.: E4X: Beginner to Advanced. http://developer.yahoo.com/flash/
articles/e4x-beginner-to-advanced.html
13. Blow, M., Goland, Y., Kloppmann, M., Leymann, F., Pfau, G., Roller, D., Rowley, M.: BPELJ;</p>
      <p>BPEL for Java. Joint white paper by BEA and IBM (March 2004)
14. Nitzsche, J., Norton, B.: Ontology based data mediation in BPEL(4SWS). In: Proceedings of
the Workshop on Semantics for Web Services (semantics4WS 2008), Milano, Italy (September
2008)</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Leymann</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roller</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Production workflow</article-title>
          .
          <source>Prentice Hall</source>
          (
          <year>2000</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>van der Aalst</surname>
            , W., van Hee,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Workflow management</article-title>
          . MIT Press (
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Leymann</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roller</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Workflow-based applications</article-title>
          .
          <source>IBM Systems Journal</source>
          <volume>36</volume>
          (
          <issue>1</issue>
          ) (
          <year>1997</year>
          )
          <fpage>102</fpage>
          -
          <lpage>123</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>A.</given-names>
            <surname>Alves</surname>
          </string-name>
          et al.:
          <source>Web Services Business Process Execution Language Version</source>
          <volume>2</volume>
          .0.
          <string-name>
            <surname>Committee</surname>
            <given-names>specification</given-names>
          </string-name>
          ,
          <source>OASIS (January</source>
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Weerawarana</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Curbera</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Leymann</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Storey</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ferguson</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Web Services Platform Architecture: SOAP, WSDL, WS-Policy, WS-Addressing, WS-BPEL, WS-Reliable Messaging and More</article-title>
          . Prentice
          <string-name>
            <surname>Hall PTR Upper Saddle</surname>
            <given-names>River</given-names>
          </string-name>
          , NJ, USA (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Christensen</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Curbera</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Meredith</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weerawarana</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <source>Web Services Description Language (WSDL) 1</source>
          .1 (
          <year>2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Clark</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , DeRose,
          <string-name>
            <given-names>S.J.: XML</given-names>
            <surname>Path</surname>
          </string-name>
          <article-title>Language (XPath) Version 1</article-title>
          .0. World Wide Web Consortium,
          <string-name>
            <surname>Recommendation</surname>
          </string-name>
          REC-xpath-
          <volume>19991116</volume>
          (
          <year>November 1999</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Adler</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Berglund</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Caruso</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Deach</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grosso</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutentag</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Milowski</surname>
            ,
            <given-names>R.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parnell</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Richman</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zilles</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Extensible Stylesheet Language (XSL) Version 1</article-title>
          .0. World Wide Web Consortium,
          <string-name>
            <surname>Recommendation</surname>
          </string-name>
          REC-xsl-
          <volume>20011015</volume>
          (
          <year>October 2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. International Organization for Standardization:
          <article-title>Information Technology - ECMAScript for XML (E4X) Specification</article-title>
          . ISO/IEC 22537:
          <year>2006</year>
          (
          <year>February 2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. Ecma International:
          <article-title>ECMAScript for XML (E4X) Specification</article-title>
          . Standard ECMA-
          <volume>357</volume>
          (
          <year>June 2004</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>