Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 65

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="15. Web Services" />
  <meta name="dc.subject" content="15. Web Services" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="webservices.html" title="Chapter Contents" />
  <link rel="prev" href="vsmx.html" title="Testing Web Published Web Services" />
  <link rel="next" href="xsql.html" title="XSQL" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>15. Web Services</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="bpel" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>15. Web Services</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="webservices.html">Chapter Contents</a> | <a class="link" href="vsmx.html" title="Testing Web Published Web Services">Prev</a> | <a class="link" href="xsql.html" title="XSQL">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="webservices.html">Web Services</a>
   </div>
    <br />
   <div>
      <a href="soap.html">SOAP</a>
   </div>
   <div>
      <a href="wsdl.html">WSDL</a>
   </div>
   <div>
      <a href="vfoafssl.html">WebID Protocol Support</a>
   </div>
   <div>
      <a href="voauth.html">OAuth Support</a>
   </div>
   <div>
      <a href="vwsssupport.html">WS-Security (WSS) Support in Virtuoso SOAP Server</a>
   </div>
   <div>
      <a href="ws-routing.html">Web Services Routing Protocol (WS-Routing)</a>
   </div>
   <div>
      <a href="warm.html">Web Services Reliable Messaging Protocol (WS-ReliableMessaging)</a>
   </div>
   <div>
      <a href="vwstrust.html">Web Services Trust Protocol (WS-Trust)</a>
   </div>
   <div>
      <a href="xmlxmla.html">XML for Analysis Provider</a>
   </div>
   <div>
      <a href="xmlrpc.html">XML-RPC support</a>
   </div>
   <div>
      <a href="syncml.html">SyncML</a>
   </div>
   <div>
      <a href="uddi.html">UDDI</a>
   </div>
   <div>
      <a href="expwsmodules.html">Exposing Persistent Stored Modules as Web Services</a>
   </div>
   <div>
      <a href="vsmx.html">Testing Web Published Web Services</a>
   </div>
   <div class="selected">
      <a href="bpel.html">BPEL Reference</a>
    <div>
        <a href="#bpelact" title="Activities">Activities</a>
        <a href="#bpelprot" title="Protocol Support">Protocol Support</a>
        <a href="#bpellifecycle" title="Process lifecycle">Process lifecycle</a>
        <a href="#bpelvdit" title="Using virtual directories">Using virtual directories</a>
        <a href="#bpelarx" title="Process archiving">Process archiving</a>
        <a href="#bpelconf" title="Configuration parameters">Configuration parameters</a>
        <a href="#bpelstats" title="Process Statistics">Process Statistics</a>
        <a href="#bpelsut" title="Deployment file suitcase format">Deployment file suitcase format</a>
        <a href="#bpelapi" title="SQL API">SQL API</a>
        <a href="#xpathbpelfunctions" title="BPEL XPath Functions">BPEL XPath Functions</a>
        <a href="#bpeltables" title="Tables">Tables</a>
        <a href="#bpelerrors" title="Errors">Errors</a>
        <a href="#bpelsampl" title="Samples">Samples</a>
        <a href="#bpelrefs" title="References">References</a>
        <a href="#bpelvadinstall" title="BPEL4WS VAD Package installation">BPEL4WS VAD Package installation</a>
    </div>
   </div>
   <div>
      <a href="xsql.html">XSQL</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="bpel" />
    <h2>15.15. BPEL Reference</h2>
    <div class="formalpara">
      <strong>Introduction</strong>
	<p>
	    Business Process Execution Language for Web Services (called BPEL4WS or simply BPEL
	    in the rest of this chapter) provides a means of specifying interactions between web services for accomplishing a potentially long running business task.
	</p>
    </div>
    <div class="formalpara">
      <strong>Used terms</strong>
	<ul>
	    <li>
          <div class="formalpara">
            <strong>WSDL</strong>
		    <p>Web Services Description Language as described in the corresponding W3C proposed recommendation.   This is a notation for declaring services and the types of data they accept and produce.
			Also the term  may be used to refer to the document containing a WSDL description.</p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>partner</strong>
		    <p>A service or application which interacts  with a BPEL process.
		    </p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>(BPEL) script</strong>
		    <p>A document containing BPEL compatible XML constructs.
		    </p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>(BPEL process) instance</strong>
		    <p>An instance of a BPEL process, can be running, suspended, aborted or finished.
		    </p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>activity</strong>
		    <p>An activity is a building block of a BPEL script. Receiving data, invoking other web services, programming language like control structures are all examples of activities.
		    </p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>portType</strong>
		    <p>Container for set of abstract operations see below.
		    </p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>operation</strong>
		    <p>An abstract black-box that have an XML input or/and output.
			Services potentially supports four types of operations:
			one-way, request-response, notification and solicit-response; this
			depends of input and/or output allowed and what is their order.
			The BPEL4WS uses one-way and request-response operations.
		        Operations are grouped in &#39;ports&#39; which define what
			operations a particular service supports.
		    </p>
	    </div>
        </li>
	    <li>
          <div class="formalpara">
            <strong>message</strong>
		    <p>An abstract XML fragment that is used for operation input and output.
			In particular this is used inside SOAP Envelope and for value of the
			BPEL variables. Also the WSDL specification specifies
			how abstract messages will be used as concrete messages using
			the SOAP protocol and which encoding will be used.
		    </p>
	    </div>
        </li>
	</ul>
    </div>
  
    <a name="bpelact" />
    <h3>15.15.1. Activities</h3>
	  
	      <a name="bpelact_common" />
    <h4>15.15.1.1. Common attributes and elements</h4>
	      <p>
		  Every BPEL activity accepts the following standard attributes: &#39;name&#39;,
		  &#39;joinCondition&#39; and &#39;suppressJoinFailure&#39;. The &#39;name&#39; attribute is an optional
		  unique within the script NCName (as defined in the XMLSchema) identifying
		  the activity.  The &#39;joinCondition&#39; is a boolean expression which determine how
		  incoming  links&#39; state will be tested, by default this is  &#39;true()&#39; which means the logical OR
		  of  the states of incoming links.
		  The &#39;suppressJoinFailure&#39; is a flag to raise or not exception if join condition
		  fails, by default this is  &#39;no&#39;.
	      </p>
	      <p>
		  The common elements for every activity are &#39;target&#39; and &#39;source&#39;. These elements
		  are used together with links and used to designate which link the current activity
		  depends on or for which one it is a prerequisite. See also section for &#39;flow&#39; activity below.
	      </p>
	  <br />
	  
	      <a name="bpelact_receive" />
    <h4>15.15.1.2. receive</h4>
	      <p>This allows the business process to do a blocking wait for a particular message to arrive.</p>
	      <p>A BPEL process instance is created by a receive activity with the createInstance attribute set to true.
	      </p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">partnerLink – </span>
		      name of a partner declared in the script from which
			  the process is to receive  a message.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">portType – </span>
		      name of the &#39;port&#39; as declared in corresponding WSDL
			  file.
		      
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">operation – </span>
		      name of the operation
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">variable – </span>
		      name of the variable to which the received message will be assigned.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">createInstance – </span>
		      used to make instance of the BPEL process and start its execution.
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;receive partnerLink=&quot;ncname&quot; portType=&quot;qname&quot; operation=&quot;ncname&quot;
    variable=&quot;ncname&quot;? createInstance=&quot;yes|no&quot;?
    standard-attributes&gt;
    standard-elements
    &lt;correlations&gt;?
        &lt;correlation set=&quot;ncname&quot; initiate=&quot;yes|no&quot;?/&gt;+
    &lt;/correlations&gt;
&lt;/receive&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_reply" />
    <h4>15.15.1.3. reply</h4>
	      <p>allows the business process to send a message in reply to a message that was received through a &lt;receive&gt;</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">partnerLink – </span>
		      name of a partner declared in the script to which
			  to send a message.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">portType – </span>
		      name of the &#39;port&#39; as declared in corresponding WSDL
			  file.
		      
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">operation – </span>
		      name of the operation
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">variable – </span>
		      name of the variable whose  value will be used as output message.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">faultName – </span>
		      
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;reply partnerLink=&quot;ncname&quot; portType=&quot;qname&quot; operation=&quot;ncname&quot;
    variable=&quot;ncname&quot;? faultName=&quot;qname&quot;?
    standard-attributes&gt;
    standard-elements
    &lt;correlations&gt;?
        &lt;correlation set=&quot;ncname&quot; initiate=&quot;yes|no&quot;?/&gt;+
    &lt;/correlations&gt;
&lt;/reply&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_invoke" />
    <h4>15.15.1.4. invoke</h4>
	      <p>This allows the business process to invoke a one-way or
		  request-response operation on a portType offered by a partner.
		  When both &#39;inputVariable&#39; and &#39;outputVariable&#39; are specified this
		  means request-response operation will be performed. Please note
		  that the  operation  is defined primarily in the partner&#39;s WSDL.
	      </p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">partnerLink – </span>
		      name of a partner declared in the script
			  to who send a message and optionally receive a response.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">portType – </span>
		      name of the &#39;port&#39; as declared in corresponding WSDL
			  file.
		      
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">operation – </span>
		      name of the operation to invoke
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">inputVariable – </span>
		      name of the variable whose  value will be used as  the message to the partner.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">outputVariable – </span>
		      name of the variable to which the response will be assigned.
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;invoke partnerLink=&quot;ncname&quot; portType=&quot;qname&quot; operation=&quot;ncname&quot;
    inputVariable=&quot;ncname&quot;? outputVariable=&quot;ncname&quot;?
    standard-attributes&gt;
    standard-elements
    &lt;correlations&gt;?
        &lt;correlation set=&quot;ncname&quot; initiate=&quot;yes|no&quot;?
            pattern=&quot;in|out|out-in&quot;/&gt;+
    &lt;/correlations&gt;
    &lt;catch faultName=&quot;qname&quot; faultVariable=&quot;ncname&quot;?&gt;*
        activity
    &lt;/catch&gt;
    &lt;catchAll&gt;?
        activity
    &lt;/catchAll&gt;
    &lt;compensationHandler&gt;?
        activity
    &lt;/compensationHandler&gt;
&lt;/invoke&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_assign" />
    <h4>15.15.1.5. assign</h4>
	      <p>can be used to update the values of variables with new data. An &lt;assign&gt; construct can contain any number of elementary assignments (copy sub-elements).</p>
	      <div>
      <pre class="programlisting">
&lt;assign standard-attributes&gt;
    standard-elements
    &lt;copy&gt;+
        from-spec
        to-spec
    &lt;/copy&gt;
&lt;/assign&gt;
</pre>
    </div>
	    <a name="from-spec" />
    <h5>15.15.1.5.1. from-spec</h5>
		<p>This represents in &lt;copy&gt; the right part of
		the assignment.</p>
	    <div>
      <pre class="programlisting">
&lt;from variable=&quot;ncname&quot; part=&quot;ncname&quot;? query=&quot;xpath-expression&quot;?/&gt;
&lt;from partnerLink=&quot;ncname&quot; endpointReference=&quot;myRole|partnerRole&quot;/&gt;
&lt;from variable=&quot;ncname&quot; property=&quot;qname&quot;/&gt;
&lt;from expression=&quot;general-expr&quot;/&gt;
&lt;from&gt;literal value&lt;/from&gt;
</pre>
    </div>
	    <br />
	    <a name="to-spec" />
    <h5>15.15.1.5.2. to-spec</h5>
		<p>This represents in &lt;copy&gt; the l-value of
		the assignment.</p>
	    <div>
      <pre class="programlisting">
&lt;from variable=&quot;ncname&quot; part=&quot;ncname&quot;? query=&quot;xpath-expression&quot;?/&gt;
&lt;from partnerLink=&quot;ncname&quot; endpointReference=&quot;myRole|partnerRole&quot;/&gt;
&lt;from variable=&quot;ncname&quot; property=&quot;qname&quot;/&gt;
</pre>
    </div>
	    <br />
	  <br />
	  
	      <a name="bpelact_throw" />
    <h4>15.15.1.6. throw</h4>
	      <p>generates a fault from inside the business process</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">faultName – </span>
		      the fault code to be thrown.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">faultVariable – </span>
		      
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;throw faultName=&quot;qname&quot; faultVariable=&quot;ncname&quot;? standard-attributes&gt;
    standard-elements
&lt;/throw&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_terminate" />
    <h4>15.15.1.7. terminate</h4>
	      <p>Used to immediately terminate the execution  of a business process instance.</p>
	      <div>
      <pre class="programlisting">
&lt;terminate standard-attributes&gt;
    standard-elements
&lt;/terminate&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_wait" />
    <h4>15.15.1.8. wait</h4>
	      <p>Wait until a given point in time  or for a specified  duration.</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">for – </span>
		      an duration expression as defined in XMLSchema (for example PT10S) 
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">until – </span>
		      an date time expression as defined in XMLSchema
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;wait (for=&quot;duration-expr&quot; | until=&quot;deadline-expr&quot;) standard-attributes&gt;
    standard-elements
&lt;/wait&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_empty" />
    <h4>15.15.1.9. empty</h4>
	      <p>insert a &quot;no-op&quot; instruction into a business process</p>
	      <div>
      <pre class="programlisting">
&lt;empty standard-attributes&gt;
    standard-elements
&lt;/empty&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_sequence" />
    <h4>15.15.1.10. sequence</h4>
	      <p>define a collection of activities to be performed sequentially in lexical order</p>
	      <div>
      <pre class="programlisting">
&lt;sequence standard-attributes&gt;
    standard-elementsactivity+
&lt;/sequence&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_switch" />
    <h4>15.15.1.11. switch</h4>
	      <p>Select exactly one branch of activity from a set of choices</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">case – </span>
		      the branch which will be executed if &#39;condition&#39; attribute returns true.
		  </div>
		  <div class="refsect2">
        <span class="refsect2title">otherwise – </span>
		      will be executed if all &#39;case&#39; conditions are evaluated to false.
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;switch standard-attributes&gt;
    standard-elements
    &lt;case condition=&quot;bool-expr&quot;&gt;+
        activity
    &lt;/case&gt;
    &lt;otherwise&gt;?
        activity
    &lt;/otherwise&gt;
&lt;/switch&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_while" />
    <h4>15.15.1.12. while</h4>
	      <p>Repeat activity while a condition is true.</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">condition – </span>
		      an XPath expression which will be evaluated every time before
			  contained activities. If this evaluates to false the loop finishes.
		      
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;while condition=&quot;bool-expr&quot; standard-attributes&gt;
    standard-elementsactivity
&lt;/while&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_pick" />
    <h4>15.15.1.13. pick</h4>
	      <p>This  blocks and waits for a suitable message to arrive or for a time-out expire. When one of the events specified in the body of the pick occurs the pick completes.  Only one of the activities in the body of the pick will actually take place.</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">createInstance – </span>
b		      This is an alternative of the &#39;receive&#39; to make a new process instance.
			  And can be expressed as: &#39;pick&#39; plus &#39;onMessage&#39; equals to &#39;receive&#39; activity.
		      
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;pick createInstance=&quot;yes|no&quot;? standard-attributes&gt;
    standard-elements
    &lt;onMessage partnerLink=&quot;ncname&quot; portType=&quot;qname&quot;
        operation=&quot;ncname&quot; variable=&quot;ncname&quot;?&gt;+
        &lt;correlations&gt;?
	    &lt;correlation set=&quot;ncname&quot; initiate=&quot;yes|no&quot;?/&gt;+
	&lt;/correlations&gt;
	activity
    &lt;/onMessage&gt;
    &lt;onAlarm (for=&quot;duration-expr&quot; | until=&quot;deadline-expr&quot;)&gt;*
	activity
    &lt;/onAlarm&gt;
&lt;/pick&gt;
</pre>
    </div>
	  <a name="pick" />
    <h5>15.15.1.13.1. onMessage</h5>
	      <p>This is to wait for an incoming message from given partner.</p>
	      <p>The attributes are the same as for <a href="#bpelact_receive">receive</a> activity</p>
	  <br />
	  <a name="pick" />
    <h5>15.15.1.13.2. onAlarm</h5>
	      <p>This will register a time-wait object whose  expiration will trigger the pick.
		  Obviously no more than one can be specified in a given  &#39;pick&#39;
	      </p>
	      <p>The attributes are the same as for the <a href="#bpelact_wait">wait</a> activity</p>
	  <br />
	  <br />
	  
	      <a name="bpelact_scope" />
    <h4>15.15.1.14. scope</h4>
	      <p>defines a nested activity with its own associated variables, fault handlers, and compensation handler</p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">variableAccessSerializable – </span>
		      
		  </div>
	      </div>
	      <div>
      <pre class="programlisting">
&lt;scope variableAccessSerializable=&quot;yes|no&quot; standard-attributes&gt;
    standard-elements
    &lt;variables/&gt;?
    &lt;correlationSets/&gt;?
    &lt;faultHandlers/&gt;?
    &lt;compensationHandler/&gt;?
    &lt;eventHandlers/&gt;?
    activity
&lt;/scope&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_flow" />
    <h4>15.15.1.15. flow</h4>
	      <p>Specifies one or more activities to be performed concurrently.
	      </p>
	      <div>
      <pre class="programlisting">
&lt;flow standard-attributes&gt;
    standard-elements
    &lt;links&gt;?
        &lt;link name=&quot;ncname&quot;/&gt;+
    &lt;/links&gt;
    activity+
&lt;/flow&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_compensate" />
    <h4>15.15.1.16. compensate</h4>
	      <p>This is used to invoke compensation on an inner scope that has already completed normally. This construct can be invoked only from within a fault handler or another compensation handler</p>
	      <div>
      <pre class="programlisting">
&lt;compensate scope=&quot;ncname&quot;? standard-attributes&gt;
    standard-elements
&lt;/compensate&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_compensationHandler" />
    <h4>15.15.1.17. compensationHandler</h4>
	      <p />
	      <div>
      <pre class="programlisting">
&lt;compensationHandler&gt;?
    activity
&lt;/compensationHandler&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_faultHandlers" />
    <h4>15.15.1.18. faultHandlers</h4>
	      <p />
	      <div>
      <pre class="programlisting">
&lt;faultHandlers&gt;?
    &lt;catch faultName=&quot;qname&quot;? faultVariable=&quot;ncname&quot;?&gt;*
        activity
    &lt;/catch&gt;
    &lt;catchAll&gt;?
        activity
    &lt;/catchAll&gt;
&lt;/faultHandlers&gt;
	      </pre>
    </div>
	  <a name="pick" />
    <h5>15.15.1.18.1. catch</h5>
	      <p>This container will be executed whose &#39;faultName&#39; attribute
		  value matches the thrown fault.</p>
	  <br />
	  <a name="pick" />
    <h5>15.15.1.18.2. catchAll</h5>
	      <p>This container will be executed if non of the
		  &#39;catch&#39; containers are matched, so if no &#39;catchAll&#39;
is 	           specified, the contained scopes will be compensated and
		   the fault will be re-thrown to the outer scope.</p>
	  <br />
	  <br />
	  
	      <a name="bpelact_eventHandlers" />
    <h4>15.15.1.19. eventHandlers</h4>
	      <p>This is a container for events, thus  it can contain onMessage or/and onAlarm
		  events. Semantic of the onMessage and onAlarm is same
		  as defined in <a href="#bpelact_pick">pick</a> activity, the
	          difference is that here these can be executed asynchronously while the events of the defining scope are running.  The events in an event handler section may thus interrupt the execution of the body of the scope.  This feature can be used for supporting asynchronous cancel messages or timeouts imposed on a whole sequence of operations..</p>
	      <div>
      <pre class="programlisting">
&lt;eventHandlers&gt;?
    &lt;onMessage partnerLink=&quot;ncname&quot; portType=&quot;qname&quot;
	operation=&quot;ncname&quot;
	variable=&quot;ncname&quot;?&gt;*

	&lt;correlations&gt;?
	    &lt;correlation set=&quot;ncname&quot; initiate=&quot;yes|no&quot;/&gt;+
	&lt;/correlations&gt;
	activity
    &lt;/onMessage&gt;
    &lt;onAlarm for=&quot;duration-expr&quot;? until=&quot;deadline-expr&quot;?&gt;*
	activity
    &lt;/onAlarm&gt;
&lt;/eventHandlers&gt;
	      </pre>
    </div>
	  <br />
	  
	      <a name="bpelact_exec" />
    <h4>15.15.1.20. exec</h4>
	      <p>This is a specific extension of the Virtuoso BPEL implementation.
		  The exec activity allows executing SQL code from inside a BPEL process without having to define a distinct SOAP service for this.
	      </p>
	      <div class="refsect1">
		  <div class="refsect2">
        <span class="refsect2title">binding – </span>
		      only &quot;SQL&quot;, &quot;JAVA&quot; and &quot;CLR&quot; are currently permitted.
		      
		  </div>
	      </div>
	  <div>
      <pre class="programlisting">
&lt;bpelv:exec binding=&quot;SQL&quot;&gt;
    insert into dummy values (&#39;hello world&#39;);
&lt;/bpelv:exec&gt;
	      </pre>
    </div>
      
	<a name="bpelact_exec_sql" />
    <h5>15.15.1.20.1. SQL execution</h5>
	<p>The additional procedures BPEL.BPEL.setVariableData and
	  BPEL.BPEL.getVariableData allow  manipulating   BPEL
	  variables. See <a href="#bpelapi">SQL API</a> for
	  details. </p>
	<p>All errors occurring  during the SQL execution are
	  translated into  BPEL errors.
	</p>
      <br />
      <a name="bpelact_exec_java" />
    <h5>15.15.1.20.2. Java execution</h5>
	<a name="bpelact_exec_java_conf" />
    <h6>Configuration</h6>
	  <p>First of all, the java support in BPEL4WS is available
	    only for java enabled virtuoso servers. In order to enable
	    java support the following administration steps need to be taken:
	  </p>
	  <ul>
	    <li>
	      1. Make java compiler (javac) available  for virtuoso
	      server
	    </li>
	    <li>
	      2. Enable &quot;system&quot; call by setting the AllowOSCalls?
	      parameter in virtuoso.ini to 1.
	    </li>
	    <li>
	      3. Add &quot;classlib&quot; directory to CLASSPATH
	    </li>
	  </ul>
	  <p>After the BPEL4WS package has been installed, the
	    server needs to be restarted.
	  </p>
	  <p>The BPEL4WS package creates the classlib directory in
	    the server&#39;s root with BpelVarsAdaptor?.class.
	     This directory and this file are necessary for the proper operation of the Java interface.
	  </p>
	<br />
	<a name="bpelact_exec_java_using" />
    <h6>Using java code in BPEL4WS</h6>
	  <p>There are two elements which support java execution in
	    BPEL4WS scripts: &lt;bpelv:exec binding=&quot;JAVA&quot; import?&gt;
	      (namespace is &quot;http://www.openlinksw.com/virtuoso/bpel&quot;)
	      and the Oracle compatible form &lt;bpelx:exec import?&gt; (namespace is
		&quot;http://schemas.oracle.com/bpel/extension&quot;). These
		tags are equal.
	  </p>
	  <p>If the tag contains the &quot;import&quot; attribute the
	    appropriate package will be imported. Example:
	  </p>
	  <div>
      <pre class="programlisting">
&lt;bpelx:exec import=&quot;java.util.*&quot;/&gt;
	    </pre>
    </div>
	  <p>Otherwise, the included code will be executed. It
	    is suggested to use &lt;![CDATA[ statement for representing
	    the java code. Example:
	  </p>
	  <div>
      <pre class="programlisting">
&lt;bpelx:exec&gt;
   System.out.println(&quot;getVariableData returned: &quot; + getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/v:destRequest/v:city&quot;));

   setVariableData (&quot;res&quot;,
         &quot;repl_payload&quot;,
         &quot;/v:destResponse/v:country&quot;,
         &quot;KZ&quot;);
&lt;/bpelx:exec&gt;
	    </pre>
    </div>
	  <p>The two &quot;functions&quot; are available for accessing  script variables:
	    setVariableData and getVariableData (analogs of the xpath functions with same names).
	  </p>
	  <div>
      <pre class="programlisting">
void setVariableData (String var_name, String part, String query_path, Object value);
	    </pre>
    </div>
	  <p>sets the variable. The value to be set is restricted
	    to be string or integer in this version.
	  </p>
	  <div>
      <pre class="programlisting">
getVariableData
	    </pre>
    </div>
	  <p> is a full analog of xpath function
	    getVariableData. See details below. </p>
	  <p> Note, the activity does not commit  changes to
	    the database until it finishes successfully, so if in a case
	    of exception the variables are kept untouched. This also
	    means that deadlocks can occur. </p>
	  <p> The communication errors must be handled and
	    processed in the java code itself. </p>
	  <p> If some unhandled exception occurs in java code,
	    it will be translated to a  BPEL error. See details in
	    the next section. </p>
	<br />
	<a name="bpelact_exec_java_errors" />
    <h6>Errors</h6>
	  <p>Two types of errors can be signalled:</p>
	  <ul>
	    <li>
	      1. upload time exceptions
	    </li>
	    <li>
	      2. runtime exceptions
	    </li>
	  </ul>
	  <p>The first type exceptions are related to configuration
	    and java syntax errors. These are as follows: </p>
	  <ul>
	    <li> 1. [BPELX] The &quot;system&quot; call is disabled, it is
	      needed for use java code in BPEL4WS scripts. * This
	      error is signalled when the &quot;AllowOSCalls&quot; is set to 0. So
	      the engine can not call java compiler. It One must  set this parameter in ini file to 1 and restart the
	      server to resolve this issue.</li>
	    <li> 2. [BPELX] Compilation  of java code for NAME
	      failed. Try to call &quot;javac NAME.java&quot; for details. * The
	      compilation of generated class for the activity has
	      failed. Try to call the suggested operation from command
	      prompt with the same PATH and CLASSPATH global
	      variables to see the javac output. </li>
	  </ul>
	  <p>Runtime errors not handled by java method itself are
	    translated to the BPEL fault in the following form:
	  </p>
	  <div>
      <pre class="programlisting">
&lt;bpws:javaFault sqlState=&quot;SQLSTATE&quot;&gt;
 error message
&lt;/bpws:javaFault&gt;
	    </pre>
    </div>
	  <p>this error can be handled by BPEL fault handler. Here
	    is an example: </p>
	  <div>
      <pre class="programlisting">
...
    &lt;receive partnerLink=&quot;caller&quot; portType=&quot;v:dest&quot; operation=&quot;check_dest&quot; variable=&quot;request&quot; createInstance=&quot;yes&quot;/&gt;
    &lt;scope&gt;
      &lt;faultHandlers&gt;
        &lt;catch faultName=&quot;bpws:javaFault&quot; faultVariable=&quot;error&quot;&gt;
          &lt;assign&gt;
            &lt;copy&gt;
              &lt;from variable=&quot;error&quot; query=&quot;/javaFault&quot;/&gt;
              &lt;to variable=&quot;res&quot; part=&quot;repl_payload&quot; query=&quot;/destResponse/country&quot;/&gt;
            &lt;/copy&gt;
          &lt;/assign&gt;
        &lt;/catch&gt;
      &lt;/faultHandlers&gt;
      &lt;bpelv:exec binding=&quot;JAVA&quot; name=&quot;invokeSomething&quot;&gt;&lt;![CDATA[
   System.out.println(&quot;Executing Java exec in BPEL&quot;);
   System.out.println(&quot;getVariableData returned: &quot; + getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/v:destRequest/v:city&quot;));

   setVariableData (&quot;res&quot;,
         &quot;repl_payload&quot;,
         &quot;/destResponse/country&quot;,
         &quot;UK&quot;);
   if (true)
     throw (new Exception(&quot;test&quot;));
   ]] &gt;
       &lt;/bpelv:exec&gt;
     &lt;/scope&gt;
    &lt;reply partnerLink=&quot;caller&quot; portType=&quot;v:dest&quot; operation=&quot;check_dest&quot; variable=&quot;res&quot;/&gt;
...
	    </pre>
    </div>
	  <p>In this code the handler for java exception is set:
	  </p>
	  <div>
      <pre class="programlisting">
...
        &lt;catch faultName=&quot;bpws:javaFault&quot; faultVariable=&quot;error&quot;&gt;
          &lt;assign&gt;
            &lt;copy&gt;
              &lt;from variable=&quot;error&quot; query=&quot;/javaFault&quot;/&gt;
              &lt;to variable=&quot;res&quot; part=&quot;repl_payload&quot; query=&quot;/destResponse/country&quot;/&gt;
            &lt;/copy&gt;
          &lt;/assign&gt;
        &lt;/catch&gt;
...
	    </pre>
    </div>
	  <p>The handler takes the error message from the variable
	    which holds it (&quot;error&quot;) and puts it into the response
	    variable. </p>
	<br />
	<a name="bpelact_exec_java_accessors" />
    <h6>BPEL variables
	    accessors</h6>
	  <div>
      <pre class="programlisting">
void setVariableData (String var_name, String part, String query_path,
	    Object value)
	    </pre>
    </div>
	  <p>- changes BPEL variable named var_name. The &quot;part&quot; is
	    a part of the message stored in the variable. &quot;query_path&quot;
	    selects the data in the variable to be changed. The
	    &quot;value&quot; can be only string or integer, so if several
	    subdata need to be changed the setVariableData must be
	    called several times. If the &quot;part&quot; and &quot;query_path&quot; must
	    be ignored their can be passed as empty strings
	    (&quot;&quot;).</p>
	  <div>
      <pre class="programlisting">
String getVariableData (String var_name, String part, String query)
	    </pre>
    </div>
	  <p> - returns selected data from the part named by &quot;part&quot;
	    argument of variable named by &quot;var_name&quot; argument. If the
	    selection failed the NULL is returned.
	  </p>
	<br />
	<a name="bpelact_exec_java_vars" />
    <h6>Special
	    variables</h6>
	  <p>There are two special variables: &quot;variables&quot; and
	    &quot;xmlnss_pre&quot;. They can be changed in the java code, in
	    this case the behaviour of the engine is
	    unpredictable. So, it is strongly recommended do not use
	    these variables. </p>
	<br />
	<a name="bpelact_exec_java_example" />
    <h6>JavaMail usage
	    example</h6>
	  <div>
      <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;process xmlns:jsm=&quot;urn:java:sendMail&quot;
	xmlns=&quot;http://schemas.xmlsoap.org/ws/2003/03/business-process/&quot;
	name=&quot;javaSendMail&quot;
	targetNamespace=&quot;urn:java:sendMail&quot;
	xmlns:bpelx=&quot;http://schemas.oracle.com/bpel/extension&quot;
	xmlns:bpelv=&quot;http://www.openlinksw.com/virtuoso/bpel&quot;&gt;

  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;java.io.*&quot;/&gt;
  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;java.net.InetAddress&quot;/&gt;
  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;java.util.Properties&quot;/&gt;
  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;java.util.Date&quot;/&gt;
  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;javax.mail.*&quot;/&gt;
  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;javax.mail.internet.*&quot;/&gt;
  &lt;bpelv:exec binding=&quot;JAVA&quot; import=&quot;com.sun.mail.smtp.*&quot;/&gt;

  &lt;partnerLinks&gt;
    &lt;partnerLink name=&quot;caller&quot; partnerLinkType=&quot;jsm:dest&quot;/&gt;
  &lt;/partnerLinks&gt;

  &lt;variables&gt;
    &lt;variable name=&quot;request&quot; messageType=&quot;jsm:destRequestMessage&quot;/&gt;
    &lt;variable name=&quot;res&quot; messageType=&quot;jsm:destResponseMessage&quot;/&gt;
  &lt;/variables&gt;
  &lt;sequence&gt;
    &lt;receive partnerLink=&quot;caller&quot; portType=&quot;jsm:dest&quot; operation=&quot;send&quot; variable=&quot;request&quot; createInstance=&quot;yes&quot;/&gt;
    &lt;bpelv:exec binding=&quot;JAVA&quot; name=&quot;sendMail&quot;&gt;&lt;![CDATA[
	String  to, subject = null, from = null;
	String mailhost = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/jsm:destRequest/jsm:mailhost&quot;);
	String mailer = &quot;OpenLink Virtuoso[BPEL script]&quot;;
	try {
        	to = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/jsm:destRequest/jsm:to&quot;);
	        subject = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/jsm:destRequest/jsm:subject&quot;);

		Properties props = System.getProperties();
		props.put(&quot;mail.smtp.host&quot;, mailhost);
		Session session = Session.getInstance(props, null);

		Message msg = new MimeMessage(session);
		if (from != null)
			msg.setFrom(new InternetAddress(from));
		else
			msg.setFrom();
		msg.setRecipients(Message.RecipientType.TO,
					InternetAddress.parse(to, false));
		msg.setSubject(subject);
	        msg.setText ((String)getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/jsm:destRequest/jsm:text&quot;));

		msg.setHeader(&quot;X-Mailer&quot;, mailer);
		msg.setSentDate(new Date());
		SMTPTransport t = (SMTPTransport)session.getTransport(&quot;smtp&quot;);
		try {
		    t.connect();
		    t.sendMessage(msg, msg.getAllRecipients());
		} finally {
		    System.out.println(&quot;Response: &quot; +
						t.getLastServerResponse());
		    t.close();
		}

	    	System.out.println(&quot;\nMail was sent successfully.&quot;);
		setVariableData (&quot;res&quot;,
			&quot;repl_payload&quot;,
			&quot;/jsm:destResponse/jsm:status&quot;,
			&quot;OK&quot;);

	} catch (Exception e) {
	    String err_str = &quot;Failed: &quot; + e.toString();
	    e.printStackTrace();
	    if (e instanceof SendFailedException) {
		MessagingException sfe = (MessagingException)e;
		if (sfe instanceof SMTPSendFailedException) {
		    SMTPSendFailedException ssfe =
				    (SMTPSendFailedException)sfe;
		    System.out.println(&quot;SMTP SEND FAILED:&quot;);
		    System.out.println(ssfe.toString());
		    System.out.println(&quot;  Command: &quot; + ssfe.getCommand());
		    System.out.println(&quot;  RetCode: &quot; + ssfe.getReturnCode());
		    System.out.println(&quot;  Response: &quot; + ssfe.getMessage());
		} else {
			System.out.println(&quot;Send failed: &quot; + sfe.toString());
		}
		Exception ne;
		while ((ne = sfe.getNextException()) != null &amp;&amp;
			ne instanceof MessagingException) {
		    sfe = (MessagingException)ne;
		    if (sfe instanceof SMTPAddressFailedException) {
			SMTPAddressFailedException ssfe =
					(SMTPAddressFailedException)sfe;
			System.out.println(&quot;ADDRESS FAILED:&quot;);
			System.out.println(ssfe.toString());
			System.out.println(&quot;  Address: &quot; + ssfe.getAddress());
			System.out.println(&quot;  Command: &quot; + ssfe.getCommand());
			System.out.println(&quot;  RetCode: &quot; + ssfe.getReturnCode());
			System.out.println(&quot;  Response: &quot; + ssfe.getMessage());
		    } else if (sfe instanceof SMTPAddressSucceededException) {
			System.out.println(&quot;ADDRESS SUCCEEDED:&quot;);
			SMTPAddressSucceededException ssfe =
					(SMTPAddressSucceededException)sfe;
			System.out.println(ssfe.toString());
			System.out.println(&quot;  Address: &quot; + ssfe.getAddress());
			System.out.println(&quot;  Command: &quot; + ssfe.getCommand());
			System.out.println(&quot;  RetCode: &quot; + ssfe.getReturnCode());
			System.out.println(&quot;  Response: &quot; + ssfe.getMessage());
		    }
		}
	    }
	    setVariableData (&quot;res&quot;,
			&quot;repl_payload&quot;,
			&quot;/jsm:destResponse/jsm:status&quot;,
			err_str);
	}

	]] &gt;&lt;/bpelv:exec&gt;
    &lt;reply partnerLink=&quot;caller&quot; portType=&quot;jsm:dest&quot; operation=&quot;send&quot; variable=&quot;res&quot;/&gt;
  &lt;/sequence&gt;
&lt;/process&gt;
	    </pre>
    </div>
	  <p> and support WSDL file: </p>
	  <div>
      <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;definitions name=&quot;javaSendMail&quot;
  targetNamespace=&quot;urn:java:sendMail&quot;
  xmlns:jsm=&quot;urn:java:sendMail&quot;
  xmlns:plnk=&quot;http://schemas.xmlsoap.org/ws/2003/05/partner-link/&quot;
  xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;&gt;
  &lt;types&gt;
    &lt;schema attributeFormDefault=&quot;qualified&quot; elementFormDefault=&quot;qualified&quot;
      targetNamespace=&quot;urn:java:sendMail&quot;
      xmlns=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
      &lt;element name=&quot;destRequest&quot;&gt;
        &lt;complexType&gt;
          &lt;sequence&gt;
            &lt;element name=&quot;mailhost&quot; type=&quot;string&quot;/&gt;
            &lt;element name=&quot;to&quot; type=&quot;string&quot;/&gt;
            &lt;element name=&quot;subject&quot; type=&quot;string&quot;/&gt;
            &lt;element name=&quot;text&quot; type=&quot;string&quot;/&gt;
          &lt;/sequence&gt;
        &lt;/complexType&gt;
      &lt;/element&gt;
      &lt;element name=&quot;destResponse&quot;&gt;
        &lt;complexType&gt;
          &lt;sequence&gt;
	    &lt;element name=&quot;status&quot; type=&quot;string&quot;/&gt;
          &lt;/sequence&gt;
        &lt;/complexType&gt;
      &lt;/element&gt;
    &lt;/schema&gt;
  &lt;/types&gt;
  &lt;message name=&quot;destRequestMessage&quot;&gt;
    &lt;part name=&quot;req_payload&quot; element=&quot;jsm:destRequest&quot;/&gt;
  &lt;/message&gt;
  &lt;message name=&quot;destResponseMessage&quot;&gt;
    &lt;part name=&quot;repl_payload&quot; element=&quot;jsm:destResponse&quot;/&gt;
  &lt;/message&gt;
  &lt;portType name=&quot;dest&quot;&gt;
    &lt;operation name=&quot;send&quot;&gt;
      &lt;input  message=&quot;jsm:destRequestMessage&quot; /&gt;
      &lt;output message=&quot;jsm:destResponseMessage&quot;/&gt;
    &lt;/operation&gt;
   &lt;/portType&gt;
   &lt;plnk:partnerLinkType name=&quot;dest&quot;&gt;
     &lt;plnk:role name=&quot;destProvider&quot;&gt;
       &lt;plnk:portType name=&quot;jsm:dest&quot;/&gt;
     &lt;/plnk:role&gt;
   &lt;/plnk:partnerLinkType&gt;
&lt;/definitions&gt;
	    </pre>
    </div>
	<br />
      <br />
      <a name="bpelact_exec_clr" />
    <h5>15.15.1.20.3. .NET CLR execution</h5>
	<a name="bpelact_exec_clr_conf" />
    <h6>Configuration</h6>
	  <p>The CLR is available only for CLR enabled Virtuoso
	    servers. In order to configure the server for CLR support
	    in BPEL4WS engine the following administration steps need
	    to be taken:
	  </p>
	  <ul>
	    <li>
	      1. Initiate &quot;CLRAssembliesDir&quot; configuration entry
	      (&quot;Directory where .NET CLR assemblies must be
	      stored&quot;) by the path where &quot;virt_bpel4ws.dll&quot;,
	      &quot;virtclr.dll&quot; etc are stored.
	    </li>
	  </ul>
	<br />
	<a name="bpelact_exec_clr_using" />
    <h6>Using the C# code
	    in BPEL4WS</h6>
	  <p>The tag for supporting CLR is &lt;exec
	    binding=&quot;CLR&quot; [using | ref ]&gt;.
	  </p>
	  <p> &lt;exec&gt; with &quot;using&quot; attribute relates to &quot;using&quot;
	    directive in C# code.
	  </p>
	  <div>
      <pre class="programlisting">
&lt;bpelv:exec binding=&quot;CLR&quot; using=&quot;System&quot;/&gt;
	  </pre>
    </div>
	  <p> in BPEL file is a substitution of  </p>
	  <div>
      <pre class="programlisting">
using System;
	    </pre>
    </div>
	  <p> statement in the C# code. </p>
	  <p> To import assemblies (with a manifest) the &lt;exec&gt; element
	    with &quot;ref&quot; attribute must be used:
	  </p>
	  <div>
      <pre class="programlisting">
&lt;bpelv:exec binding=&quot;CLR&quot; ref=&quot;metad1.dll&quot;/&gt;
&lt;bpelv:exec binding=&quot;CLR&quot; ref=&quot;d:\\myassemblies\\sms_service.dll&quot;/&gt;
	    </pre>
    </div>
	  <p>If the tag does not contain these attributes then the
	    content of the tag is treated as C# code. It is suggested
	    to use CDATA sections for the code. Example:
	  </p>
	  <div>
      <pre class="programlisting">
&lt;bpelv:exec binding=&quot;CLR&quot; name=&quot;invokeSomething&quot;&gt;&lt;![CDATA[

	Console.WriteLine(&quot;Executing CLR assembly in BPEL&quot;);
	Console.WriteLine(&quot;getVariableData returned: &quot; + getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/tns:destRequest/tns:city&quot;));

	setVariableData (&quot;res&quot;,
			&quot;repl_payload&quot;,
			&quot;/destResponse/country&quot;,
			&quot;UK&quot;);
]] &gt;&lt;/bpelv:exec&gt;
	    </pre>
    </div>
	  <p>Two &quot;functions&quot; are available for accessing script variables: setVariableData and
	    getVariableData (analogs of the xpath functions with same
	    names).
	  </p>
	  <div>
      <pre class="programlisting">
void setVariableData (String var_name, String part, String query_path, Object value);
	    </pre>
    </div>
	  <p>sets the variable. The value to be set is restricted
	    to be string or integer in this version.
	  </p>
	  <div>
      <pre class="programlisting">
Object getVariableData (String var_name, String part, String query)
	    </pre>
    </div>
	  <p> is a full analog of xpath function
	    getVariableData. See details below. </p>
	  <p> Note, the activity does not commit  changes to
	    the database until it finishes successfully, so in a case
	    of exception the variables are kept untouched. This also
	    means that deadlocks can not occur during C# code
	    execution (naturally, this statement is not true if the
	    code contains direct invocation of SQL through the
	    &quot;in-process&quot; .NET provider).</p>
	  <p> If the some unhandled exception occurred in C# code,
	    it will be translated to a BPEL error. See details in
	    the next section. </p>
	<br />
	<a name="bpelact_exec_clr_errors" />
    <h6>Runtime
	    Errors</h6>
	    <p> Runtime errors not handled by CLR itself are translated to the BPEL fault in the following form:</p>
	    <div>
      <pre class="programlisting">
&lt;bpws:clrFault sqlState=&quot;SQLSTATE&quot;&gt;
 error message
&lt;/bpws:javaFault&gt;
	    </pre>
    </div>
	    <p>this error can be handled by BPEL fault handler. Here is an example:</p>
	    <div>
      <pre class="programlisting">
...
    &lt;scope&gt;
      &lt;faultHandlers&gt;
        &lt;catch faultName=&quot;bpws:clrFault&quot; faultVariable=&quot;error&quot;&gt;
          &lt;assign&gt;
            &lt;copy&gt;
              &lt;from variable=&quot;error&quot; query=&quot;/clrFault/text()&quot;/&gt;
              &lt;to variable=&quot;res&quot; part=&quot;repl_payload&quot; query=&quot;/clr:destResponse/clr:status&quot;/&gt;
            &lt;/copy&gt;
          &lt;/assign&gt;
        &lt;/catch&gt;
      &lt;/faultHandlers&gt;
      &lt;bpelv:exec binding=&quot;CLR&quot; name=&quot;Hotmail&quot;&gt;&lt;![CDATA[
	     String login, passwd;
        	login = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/clr:destRequest/clr:login&quot;);
	       	passwd = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/clr:destRequest/clr:password&quot;);
		Console.WriteLine (&quot;user:&quot; + login + &quot; password:&quot; + passwd);

		HotmailUsage usage = new HotmailUsage();
		Console.WriteLine (&quot;Result: &quot; + usage.Call_Hotmail (login, passwd));

		setVariableData (&quot;res&quot;,
			&quot;repl_payload&quot;,
			&quot;/clr:destResponse/clr:status&quot;,
			&quot;OK&quot;);
	]] &gt;&lt;/bpelv:exec&gt;
	&lt;/scope&gt;
    &lt;reply partnerLink=&quot;caller&quot; portType=&quot;clr:dest&quot; operation=&quot;send&quot; variable=&quot;res&quot;/&gt;
...
    </pre>
    </div>
	    <p>In this code the handler for CLR exception is set:</p>
	    <div>
      <pre class="programlisting">
...
        &lt;catch faultName=&quot;bpws:clrFault&quot; faultVariable=&quot;error&quot;&gt;
          &lt;assign&gt;
            &lt;copy&gt;
              &lt;from variable=&quot;error&quot; query=&quot;/clrFault/text()&quot;/&gt;
              &lt;to variable=&quot;res&quot; part=&quot;repl_payload&quot; query=&quot;/clr:destResponse/clr:status&quot;/&gt;
            &lt;/copy&gt;
          &lt;/assign&gt;
        &lt;/catch&gt;
...
	    </pre>
    </div>
	    <p>The handler takes the error message from the variable which holds it (&quot;error&quot;) and puts it into the response variable.</p>
	<br />
	<a name="bpelact_exec_clr_accessors" />
    <h6>BPEL variable
	    accessors</h6>
	  The name and the signature of BPEL accessors for CLR are
	  fully equal to the java accessors. See
	  <a href="#bpelact_exec_java_accessors">java
	    section</a> for details.
	<br />
	<a name="bpelact_exec_clr_vars" />
    <h6>Special
	    variables</h6>
	  The special variables for CLR are the same as for Java.
	  See <a href="#bpelact_exec_java_vars">java
	    section</a> for details.
	<br />
	<a name="bpelact_exec_clr_sample" />
    <h6>CLR Sample</h6>
	  <div>
      <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;process xmlns:clr=&quot;urn:clr:Hotmail&quot;
        xmlns=&quot;http://schemas.xmlsoap.org/ws/2003/03/business-process/&quot;
        name=&quot;clrHotmail&quot;
        targetNamespace=&quot;urn:clr:Hotmail&quot;
        xmlns:bpelx=&quot;http://schemas.oracle.com/bpel/extension&quot;
        xmlns:bpelv=&quot;http://www.openlinksw.com/virtuoso/bpel&quot;&gt;

  &lt;bpelv:exec binding=&quot;CLR&quot; using=&quot;HotmailUsageChecker&quot;/&gt;
  &lt;bpelv:exec binding=&quot;CLR&quot; ref=&quot;l:\\distrib_3_0\\bin\\Hotmail.dll&quot;/&gt;
  &lt;bpelv:exec binding=&quot;CLR&quot; using=&quot;System&quot;/&gt;

  &lt;partnerLinks&gt;
    &lt;partnerLink name=&quot;caller&quot; partnerLinkType=&quot;clr:dest&quot;/&gt;
  &lt;/partnerLinks&gt;

  &lt;variables&gt;
    &lt;variable name=&quot;request&quot; messageType=&quot;clr:destRequestMessage&quot;/&gt;
    &lt;variable name=&quot;res&quot; messageType=&quot;clr:destResponseMessage&quot;/&gt;
  &lt;/variables&gt;
  &lt;sequence&gt;
    &lt;receive partnerLink=&quot;caller&quot; portType=&quot;clr:dest&quot; operation=&quot;send&quot; variable=&quot;request&quot; createInstance=&quot;yes&quot;/&gt;
    &lt;scope&gt;
      &lt;faultHandlers&gt;
        &lt;catch faultName=&quot;bpws:clrFault&quot; faultVariable=&quot;error&quot;&gt;
          &lt;assign&gt;
            &lt;copy&gt;
              &lt;from variable=&quot;error&quot; query=&quot;/clrFault/text()&quot;/&gt;
              &lt;to variable=&quot;res&quot; part=&quot;repl_payload&quot; query=&quot;/clr:destResponse/clr:status&quot;/&gt;
            &lt;/copy&gt;
          &lt;/assign&gt;
        &lt;/catch&gt;
      &lt;/faultHandlers&gt;
      &lt;bpelv:exec binding=&quot;CLR&quot; name=&quot;Hotmail&quot;&gt;&lt;![CDATA[
             String login, passwd;
                login = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/clr:destRequest/clr:login&quot;);
                passwd = (String) getVariableData (&quot;request&quot;, &quot;req_payload&quot;, &quot;/clr:destRequest/clr:password&quot;);
                Console.WriteLine (&quot;user:&quot; + login + &quot; password:&quot; + passwd);

                HotmailUsage usage = new HotmailUsage();
                Console.WriteLine (&quot;Result: &quot; + usage.Call_Hotmail (login, passwd));

                setVariableData (&quot;res&quot;,
                        &quot;repl_payload&quot;,
                        &quot;/clr:destResponse/clr:status&quot;,
                        &quot;OK&quot;);
        ]]&gt;&lt;/bpelv:exec&gt;
        &lt;/scope&gt;
    &lt;reply partnerLink=&quot;caller&quot; portType=&quot;clr:dest&quot; operation=&quot;send&quot; variable=&quot;res&quot;/&gt;
  &lt;/sequence&gt;
&lt;/process&gt;
	  </pre>
    </div>
	<br />
      <br />
    <br />
  <br />
  
      <a name="bpelprot" />
    <h3>15.15.2. Protocol Support</h3>
      <p>
The Virtuoso BPEL implementation supports WS Security and WS Reliable Messaging.  These protocols may be enabled and configured for individual partner links.
	  The WS-Addressing protocol is automatically used when the partner
	  has such capabilities.
      </p>
      <p>
	  The Partner link options are stored in XML format in the
	  &#39;BPEL.BPEL.partner_link_init&#39; table  in &#39;bpl_opts&#39; column.
	  See the document format and table description below in this chapter.
      </p>
	  
	      <a name="bpelprotwsa" />
    <h4>15.15.2.1. WS-Addressing (WSA)</h4>
	      <p>WS-Addressing is transparently handled via
		  WSDL description and request of the partner(s).
		  If the partner has WSA headers exposed then the corresponding
		  operation will be invoked with WSA headers. If the partner
		  uses WSA to call the BPEL service then the service will respond to
		  the partner with WSA headers included.
	      </p>
	      <p>
		  The benefit of using WSA consists in transparently handled
		  message correlation via &quot;MessageID&quot; and &quot;RelatesTo&quot; headers. Thus no
		  explicit message correlation needs to be specified when the partner is WSA capable
		  (see <a href="/tutorial/services/bp_s_1/bp_s_1.vsp">LoanFlow</a>
		  demo in tutorials to see how this works).
		  Also when the reply is asynchronous the return path can  be handled via
		  the &quot;ReplyTo&quot; WSA headers.
	      </p>
	      <p>
		 As WSA has different  revisions that are supported by different
		 implementations (partners), the version of the protocol
		 is configurable via wsOptions/addressing element (see below).
	     </p>
	     <p>
		 The &#39;wsa&#39; partner link option can be used in <a href="bpel.html#bpelplinkconf">API</a> functions
		 to set or retrieve the value of the wsOptions/addressing.
	     </p>
	  <br />
	  
	      <a name="bpelprotwss" />
    <h4>15.15.2.2. WS-Security (WSS)</h4>
	      <p>There are several cases where privacy and confidentiality
		  must be observed , this is especially true when business processes
		  involve  payment systems, personal information etc.
		  In those cases a partner may,  depending on Web Service policy,
		  require secure messages (signed, encrypted or both).
		  Such partners usually do not expose (for many reasons) in WSDL the WSS headers,
		  hence this must be configured by  the BPEL administrator per partner.
	      </p>
	      <p>In order for the BPEL server to be able to sign and encrypt messages
		  keys have to be uploaded into the BPEL user repository.
		  This can be done with the USER_KEY_LOAD() function or using the
		  BPEL GUI (Partner Link properties).
	      </p>
	      <p>
		  It is important to know the following basics:
	      </p>
	      <ul>
		  <li>
		  The  private key is needed in order to decrypt or sign messages.
	      </li>
		  <li>
		  The partner public key is needed to encrypt  messages or verify
		  signatures.
	      </li>
	      </ul>
	      <p>
		  These keys have to be described in wsOptions/security/key and wsOptions/security/pubkey
		  in the &#39;Partner link options&#39; XML document. Note that in the options document are stored only
		  the names of the keys, as the keys themselves  are registered in the BPEL user key repository.
	      </p>
	     <p>
		 Note: Use the &#39;wss-priv-key&#39; and &#39;wss-pub-key&#39; partner link option in
		 <a href="bpel.html#bpelplinkconf">API</a> functions to set or change the value of them.
	     </p>
	      <p>
		  The encryption and signing is independently configurable for outbound
		  or inbound messages. This is settable via the following options:
	      </p>
	      <ul>
		  <li>
		      wsOptions/security/in/encrypt - &#39;Optional&#39;: inbound message MAY be
		      encrypted, &#39;Mandatory&#39;: inbound message MUST be encrypted
		      (&#39;wss-in-encrypt&#39; option <a href="bpel.html#bpelplinkconf">in API</a>)
		  </li>
		  <li>
		      wsOptions/security/in/signature - same as encryption but
		      for XML signature (&#39;wss-in-signature&#39; option <a href="bpel.html#bpelplinkconf">in API</a>)
		  </li>
		  <li>
		      wsOptions/security/in/keys - this is a list of keys (key names)
		      that are trusted; only SOAP messages signed with one of these
		      keys will be accepted. If this list is empty, all parties will
		      be accepted unless signature is invalid or message
		      can not be decrypted. (&#39;wss-in-signers&#39; option <a href="bpel.html#bpelplinkconf">in API</a>)
		  </li>
		  <li>
		      wsOptions/security/out/encrypt - type of the session key for encryption
		      3DES, AES128, AES192 or AES256. (&#39;wss-out-encrypt-key&#39; option <a href="bpel.html#bpelplinkconf">in API</a>)
		  </li>
		  <li>
		      wsOptions/security/out/signature -
		      &#39;Default&#39;: the WSS default template (see WS-Security chapter for details),
		      &#39;Custom&#39;: in this case &#39;function&#39; attribute must refer to a PL procedure
		      returning XML Signature template. (&#39;wss-out-signature-type&#39; and &#39;wss-out-signature-function&#39;
		      options <a href="bpel.html#bpelplinkconf">in API</a>)
		  </li>
	      </ul>
	  <br />
	  
	      <a name="bpelprotwsrm" />
    <h4>15.15.2.3. WS-Reliable Messaging (WSRM)</h4>
	      <p>The WSRM is applicable for those partners which can be invoked asynchronously.
		  For both inbound or outbound (from the point of view of the process)
		  WSRM  can be enabled. The options are
		  settable in wsOptions/delivery/in or wsOptions/delivery/out
		  (&#39;wsrm-in-type&#39; and &#39;wsrm-out-type&#39; options <a href="bpel.html#bpelplinkconf">in API</a>)
		  respectively.
	      </p>
	      <ul>
		  <li>
		      ExactlyOnce - message will be delivered only once to the destination.
		  </li>
		  <li>
		      InOrder - messages will be delivered in the same order as they are
		      sent from the script.
		  </li>
	      </ul>
	  <br />
	  
	      <a name="bpelprothttpauth" />
    <h4>15.15.2.4. HTTP security</h4>
	      <p>
		  Some partner services may require HTTPS or/and HTTP authentication
		  instead of using WS-Security protocol to ensure SOAP message privacy.
	      </p>
	      <p>
		  When a partner&#39;s endpoint URL contains HTTPS scheme (like https://)
		  the request and response operations will be made with HTTP over SSL (HTTPS protocol).
		  In this case no additional options to the partner links are needed.
	      </p>
	      <p>
		  In case when a partner service needs a HTTP authentication, the
		  user name and password (for that service) needs to be configured for
		  the given partner link. These are settable via wsOptions/security/http-auth
		  (&#39;http-auth-uid&#39; and &#39;http-auth-pwd&#39; options <a href="bpel.html#bpelplinkconf">in API</a>)
		  element in partner link options. Note that only basic HTTP authentication is
		  supported.
	      </p>
	  <br />
	  <p>Partner link options format</p>
	  <div>
      <pre class="programlisting">
&lt;wsOptions&gt;
    &lt;!-- WSA revision namespace --&gt;
    &lt;addressing version=&quot;http://schemas.xmlsoap.org/ws/2003/03/addressing|http://schemas.xmlsoap.org/ws/2004/03/addressing&quot;/|http://schemas.xmlsoap.org/ws/2004/08/addressing&gt;
  &lt;!-- WSS options --&gt;
  &lt;security&gt;
      &lt;!-- basic HTTP Authentication --&gt;
      &lt;http-auth username=&quot;&quot; password=&quot;&quot;/&gt;
      &lt;!-- WSS keys --&gt;
      &lt;key name=&quot;[Private Key]&quot;/&gt;
      &lt;pubkey name=&quot;[Partner public key]&quot;/&gt;
    &lt;in&gt;
      &lt;encrypt type=&quot;NONE|Optional|Mandatory&quot;/&gt;
      &lt;signature type=&quot;NONE|Optional|Mandatory&quot; /&gt;
      &lt;keys&gt;
	  &lt;!-- trusties --&gt;
	  &lt;key name=&quot;[Trusted Public Key]&quot;/&gt;
	  ...
      &lt;/keys&gt;
    &lt;/in&gt;
    &lt;out&gt;
	&lt;encrypt type=&quot;NONE|3DES|AES128|AES192|AES256&quot;/&gt;
	&lt;signature type=&quot;NONE|Default|Custom&quot; function=&quot;[PL procedure name]&quot;/&gt;
    &lt;/out&gt;
  &lt;/security&gt;
  &lt;!-- WSRM options --&gt;
  &lt;delivery&gt;
    &lt;in  type=&quot;NONE|ExactlyOnce|InOrder&quot;/&gt;
    &lt;out type=&quot;NONE|ExactlyOnce|InOrder&quot; /&gt;
  &lt;/delivery&gt;
&lt;/wsOptions&gt;
	
    </pre>
    </div>
    
	<a name="bpelplinkconf" />
    <h4>15.15.2.5. Configuring the Partner link options</h4>
	<p>
	    The partner link options can be configured vi BPEL UI (http://host:port/BPELGUI)
	    or programmatically using <a href="fn_plink_get_option.html">plink_get_option()</a> and <a href="fn_plink_set_option.html">plink_set_option()</a> functions. It is
	    possible to update the partner link options with SQL update statement using
	    the configuration (described above), but use
	    of the BPEL UI or API functions is recommended.
	</p>
    <br />

    
	<a name="bpeldynpl" />
    <h4>15.15.2.6. Dynamic Partner Links</h4>
	<p>
The &#39;assign&#39; activity allows
	    partner links to be assigned values at run time.
This means that partner links can be dynamic and that a process may call partners that were not known at the time of defining the process.
Partner links can be defined at run time using the  &#39;EndpointReference&#39; element
	    from the WS-Addressing specification :
	</p>
	<div>
      <pre class="programlisting">
  &lt;xs:element name=&quot;EndpointReference&quot; type=&quot;wsa:EndpointReferenceType&quot;/&gt;
  &lt;xs:complexType name=&quot;EndpointReferenceType&quot;&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name=&quot;Address&quot; type=&quot;wsa:AttributedURI&quot;/&gt;
      &lt;xs:element name=&quot;ReferenceProperties&quot; type=&quot;wsa:ReferencePropertiesType&quot; minOccurs=&quot;0&quot;/&gt;
      &lt;xs:element name=&quot;PortType&quot; type=&quot;wsa:AttributedQName&quot; minOccurs=&quot;0&quot;/&gt;
      &lt;xs:element name=&quot;ServiceName&quot; type=&quot;wsa:ServiceNameType&quot; minOccurs=&quot;0&quot;/&gt;
      &lt;xs:any namespace=&quot;##other&quot; processContents=&quot;lax&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot; /&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace=&quot;##other&quot; processContents=&quot;lax&quot;/&gt;
  &lt;/xs:complexType&gt;
	
    </pre>
    </div>
    <p>
	Thus it may keep endpoint URL, Port type, Service name and
	any number of implementation specific options under &#39;ReferenceProperties&#39;.
	Also it may keep any other extensible elements and attributes.
    </p>

    <p>
	The Virtuoso BPEL implementation extends the EndpointReferenceType
	with element &#39;wsOptions&#39; under WSA element &#39;ReferenceProperties&#39; (see previous section
	for &#39;wsOptions&#39; element description).
	Thus it is possible to decide at  run time to send a secure reply  (WSS)
	or to use reliable messaging (WSRM). The following excerpt shows BPEL source that
	assigns  WS Security options to a partner link:
    </p>
    <div>
      <pre class="programlisting">
      ...
      &lt;assign&gt;
	  &lt;copy&gt;
	      &lt;from&gt;
		  &lt;EndpointReference xmlns=&quot;http://schemas.xmlsoap.org/ws/2003/03/addressing&quot;&gt;
		      &lt;Address&gt;http://securehost/myService&lt;/Address&gt;
		      &lt;ReferenceProperties&gt;
			  &lt;wsOptions xmlns=&quot;&quot;&gt;
			      &lt;addressing version=&quot;http://schemas.xmlsoap.org/ws/2003/03/addressing&quot;/&gt;
			      &lt;security&gt;
				  &lt;http-auth username=&quot;&quot; password=&quot;&quot;/&gt;
				  &lt;key name=&quot;myKey&quot;/&gt;
				  &lt;pubkey name=&quot;serverKey&quot;/&gt;
				  &lt;in&gt;
				      &lt;encrypt type=&quot;Optional&quot;/&gt;
				      &lt;signature type=&quot;Optional&quot; /&gt;
				      &lt;keys/&gt;
				  &lt;/in&gt;
				  &lt;out&gt;
				      &lt;encrypt type=&quot;AES128&quot;/&gt;
				      &lt;signature type=&quot;Default&quot;/&gt;
				  &lt;/out&gt;
			      &lt;/security&gt;
			  &lt;/wsOptions&gt;
		      &lt;/ReferenceProperties&gt;
		  &lt;/EndpointReference&gt;
	      &lt;/from&gt;
	      &lt;to partnerLink=&quot;service&quot;/&gt;
	  &lt;/copy&gt;
      &lt;/assign&gt;
      ...
	
    </pre>
    </div>
    <p>
	To manipulate the partner link options and endpoint URL we can also use
	variables declared as element EndpointReference from WS-Addressing schema.
    </p>
    <br />
  <br />
  
      <a name="bpellifecycle" />
    <h3>15.15.3. Process lifecycle</h3>
      <p>A BPEL process may have more than one version during development
	  or maintenance in production environment. This means the process may have a
	  more than one copy on the server where one of these copies is current
	  all others are either obsolete or in the process of being defined . We will call
	  these states further in this section as &#39;current&#39;, &#39;obsolete&#39; or &#39;edit&#39; (versions).
	  The link  between these versions is the process name which  remains the same during
	  process life-cycle.
      </p>
      <p>
	  When a process is compiled for the first time it becomes &#39;current&#39;.
   The current version of a process is the one that was most recently compiled without errors.
   Only a current version of a process can make new instances in response to receiving messages.
   For a single process name only one version can be current at any one time.  The other compiled versions of the process are always obsolete, meaning that new instances cannot be created but that old instances may proceed and complete.

      </p>
      <p>
	  The &#39;obsolete&#39; version
	  can not crate new process instances, it may only receive messages for its
	  instances which are still running or suspended. In other words the old
	  process instances will continue and any new instances  will be   instances
	  of the current version.
      </p>
      <p>
	  The &#39;edit&#39; state means that a new copy of the process is created but it
	  is still not compiled. After successful compilation, a process
          in the edit state is set into the current state and the formerly current process is set to the the obsolete state.
      </p>
      <p>
	  All process versions may have only one endpoint corresponding to
	  the process. The BPEL administrator  MUST take care about endpoints to
          make sure that clients using the process are compatible with
	  different process versions.
	  This means that if changes in new versions are for example in the
	  logic but not in the process&#39; WSDL then new endpoint is not needed in most  cases;
	  furthermore in this case clients will be compatible with new input and output message structure;
	  except in the case where the same messages are used  with logically different meaning.
	  So when a new process version involves significant
	  change to messages then the new process should have a new endpoint and WSDL description.
      </p>
  <br />
  
      <a name="bpelvdit" />
    <h3>15.15.4. Using virtual directories</h3>
      <p>
	  To allow a process to make new instances or to
	  receive messages from remote services in asynchronous way
	  it needs an endpoint. Endpoint means an URL that allows
	  to accept and process known SOAP messages.
      </p>
      <p>
	  Every process has  a default endpoint which is accessible via the
	  &#39;http://[host:port]/BPELGUI/bpel.vsp?script=[process_name]&#39; URL.
	  Also it has  a default WSDL document describing the process
	  at URL http://[host:port]/BPELGUI/bpel.vsp?script=[process_name]&amp;wsdl.
	  Upon compilation a different virtual directory can be specified
	  for the process. For example if &#39;/Service&#39; is specified the
	  &#39;http://[host:port]/Service&#39; would be the endpoint URL also in this
	  case the WSDL will be available on &#39;http://[host:port]/Service?wsdl&#39;.
      </p>
      <p>
	  It is important to note that changing the virtual directory when a process
	  is redefined will force all clients to update their configuration.
	  This is the case when a major changes
	  are made to the process and clients need to be re-linked
	  against new WSDL.
	  So when changes are small there will be no  need of a new virtual directory.
	   (See section &#39;Process life-cycle&#39; above
	  for process versions).
      </p>
  <br />
  
      <a name="bpelarx" />
    <h3>15.15.5. Process archiving</h3>
      <p>When an instance of a BPEL process is completed
	  it will be archived and purged from system after
	  a configurable time interval.
	  The interval is settable via &#39;InstanceExpiryDelay&#39;
	  configuration option (see below how to change).
	  The default interval for archiving is one day.
      </p>
      <p>The archive file contains
	  status of the instance which is archived,
	  execution path of the activities when execution is completed,
          value of the variables and partner links.</p>
      <p>
	  The format of the archive file is as follows:
      </p>
      <div>
      <pre class="programlisting">
&lt;instances&gt;
  &lt;instance id=&quot;[instance id]&quot;&gt;
    &lt;status code=&quot;[2 - success |3 - error]&quot; error=&quot;[error description]&quot;/&gt;
    &lt;execution&gt;
	&lt;node id=&quot;[activity id]&quot; type=&quot;[activity type]&quot;/&gt;
	... more nodes may follow ...
    &lt;/execution&gt;
    &lt;variables&gt;
	&lt;variable name=&quot;[name of the variable]&quot;&gt;... variable value ...&lt;/variable&gt;
	... more variables may follow ...
    &lt;/variables&gt;
    &lt;partnerLinks&gt;
      &lt;partnerLink name=&quot;[name of the partner link]&quot;&gt;
        &lt;EndpointReference&gt;
	    &lt;Address&gt;... partner link endpoint ...&lt;/Address&gt;
        &lt;/EndpointReference&gt;
      &lt;/partnerLink&gt;
      ... more partner links may follow ...
    &lt;/partnerLinks&gt;
  &lt;/instance&gt;
&lt;/instances&gt;
	  </pre>
    </div>
  <br />
  
      <a name="bpelconf" />
    <h3>15.15.6. Configuration parameters</h3>
      <p>The BPEL engine has  global configuration parameters settable via the configuration settings page of its web user interface.
	  These are global and are kept in the BPEL..configuration table as name/value pairs.
      </p>
      <ul>
	  <li>
	      EngineMailAddress - e-mail address to whom will be sent error alerts and reports.
	  </li>
	  <li>
	      ErrorAlertSkeleton - e-mail template for error alerts
	  </li>
	  <li>
	      ErrorReportSkeleton - e-mail template for error reports
	  </li>
	  <li>
	      AlertSubject - Subject for error alert e-mail
	  </li>
	  <li>
	      CommonEmailHeader - Header for all BPEL e-mail notifications
	  </li>
	  <li>
	      ErrorSubject - Subject for error report e-mail
	  </li>
	  <li>
	      InstanceExpiryDelay - how long (hours a completed instance will be kept in the database before purging.
	  </li>
	  <li>
	      MailServer - if specified this will be used to send the error alerts and reports.
	      If this is not specified the default (from INI file) mail server will be used.
	  </li>
	  <li>
	      Statistics - process statistics flag, if 0 (default) the statistics collection
	      is disabled. When this is  1 the engine will start collecting statistics for
	      new process instances .
	  </li>
      </ul>
  <br />
  
      <a name="bpelstats" />
    <h3>15.15.7. Process Statistics</h3>
      <p>
	  The BPEL process can be set to collect
	  statistics, this can  be enabled by  turning on the statistics flag
	  (see Configuration section). If the statistics flag is on the
	  following data is available:
      </p>

      <ul>
	  <li>
	      count of instance creations per instance creating partner link
	  </li>
	  <li>
	      count/duration/data volume of invokes per invoked synchronous partner link
	  </li>
	  <li>
	      count/data volume per asynchronous partner link
	  </li>
	  <li>
	      waiting time/count/data volume at non-instance creating receives
	  </li>
	  <li>
	      average time to complete for process
	  </li>
	  <li>
	      Errors per partner link
	  </li>
	  <li>
	      count of created instances
	  </li>
	  <li>
	      count of completed instances
	  </li>
	  <li>
	      count of instances that could not terminate successfully
	  </li>
      </ul>
  <br />
  
      <a name="bpelsut" />
    <h3>15.15.8. Deployment file suitcase format</h3>
      <p>The relation between a BPEL process and
	  different partner links can be stored in a deployment file.
	  This file contains a description for every partner link
	  mention in the process.
	  The descriptor  file simplifies deployment.  Entering the URL of this file through the web administration interface
	   will download and register
	  all sources needed for the process compilation.
      </p>
      <p>The format of the deployment file is as follows:</p>
      <div>
      <pre class="programlisting">
    &lt;BPELSuitcase&gt;
        &lt;BPELProcess id=&quot;[process id]&quot; src=&quot;[URI of the file containing BPEL script]&quot;&gt;
		&lt;partnerLinkBindings&gt;
			&lt;partnerLinkBinding name=&quot;[name of the partner]&quot;&gt;
			    &lt;property name=&quot;wsdlLocation&quot;&gt;[URI of the WSDL for the partner]&lt;/property&gt;
			&lt;/partnerLinkBinding&gt;
			... more partnerLinkBinding may follow ...
		&lt;/partnerLinkBindings&gt;
	&lt;/BPELProcess&gt;
    &lt;/BPELSuitcase&gt;
    </pre>
    </div>
  <br />
  
      <a name="bpelapi" />
    <h3>15.15.9. SQL API</h3>
      <p>
	  The following API functions are available:
      </p>


<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_compile_script" />
	  <span class="funcdef">
      <a href="fn_bpel_compile_script.html">
            <span class="function">BPEL.BPEL.compile_script</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">scp_id</span> int</span>, 
        <span class="paramdef">in <span class="parameter">vdir</span> varchar (default null)</span>, 
        <span class="paramdef">in <span class="parameter">opts</span> any (default null)</span>, 
        <span class="paramdef">in <span class="parameter">no_check</span> int (default 0)</span>);
      </div>
    </div>
    <p>Compile a BPEL script source</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_copy_script" />
        <span class="funcdef">
      <a href="fn_bpel_copy_script.html">
            <span class="function">BPEL.BPEL.copy_script</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">scp_id</span> int</span>);
      </div>
    </div>
    <p>Makes a copy of an existing script</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_get_partner_links" />
        <span class="funcdef">
      <a href="fn_bpel_get_partner_links.html">
            <span class="function">BPEL.BPEL.get_partner_links</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">scp_id</span> int</span>);
      </div>
    </div>
    <p>Returns a list of partner links used in the BPEL script</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_instance_delete" />
        <span class="funcdef">
      <a href="fn_bpel_instance_delete.html">
            <span class="function">BPEL.BPEL.instance_delete</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">id</span> int</span>);
      </div>
    </div>
    <p>delete a BPEL process instance</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_purge" />
        <span class="funcdef">
      <a href="fn_bpel_purge.html">
            <span class="function">BPEL.BPEL.purge_instance</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">completed_before</span> datetime</span>, 
        <span class="paramdef">in <span class="parameter">make_archive</span> int (default 1)</span>);
      </div>
    </div>
    <p>removes old BPEL process instances</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_script_delete" />
        <span class="funcdef">
      <a href="fn_bpel_script_delete.html">
            <span class="function">BPEL.BPEL.script_delete</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">script</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">delete_instances</span> int</span>);
      </div>
    </div>
    <p>Remove a BPEL process</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_script_obsolete" />
        <span class="funcdef">
      <a href="fn_bpel_script_obsolete.html">
            <span class="function">BPEL.BPEL.script_obsolete</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">script</span> varchar</span>);
      </div>
    </div>
    <p>mark a BPEL script as obsoleted</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_script_source_update" />
	  <span class="funcdef">
      <a href="fn_bpel_script_source_update.html">
            <span class="function">BPEL.BPEL.script_source_update</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">scp_id</span> int</span>, 
        <span class="paramdef">in <span class="parameter">url</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">content</span> any</span>);
      </div>
    </div>
    <p>Updates an existing script in BPEL repository</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_script_upload" />
        <span class="funcdef">
      <a href="fn_bpel_script_upload.html">
            <span class="function">BPEL.BPEL.script_upload</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">name</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">url</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">content</span> any</span>);
      </div>
    </div>
    <p>Upload a new BPEL script source</p>





<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_wsdl_upload" />
        <span class="funcdef">
      <a href="fn_bpel_wsdl_upload.html">
            <span class="function">BPEL.BPEL.wsdl_upload</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">scp_id</span> int</span>, 
        <span class="paramdef">in <span class="parameter">url</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">content</span> any</span>, 
        <span class="paramdef">in <span class="parameter">pl</span> varchar default &#39;wsdl&#39;</span>);
      </div>
    </div>
    <p>Uploads a WSDL description for a given BPEL script</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_plink_get_option" />
        <span class="funcdef">
      <a href="fn_plink_get_option.html">
            <span class="function">BPEL.BPEL.plink_get_option</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">script</span> varchar</span>, 
	<span class="paramdef">in <span class="parameter">plink</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">opt</span> varchar</span>);
      </div>
    </div>
    <p>retrieving a partner link option</p>



<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_plink_set_option" />
        <span class="funcdef">
      <a href="fn_plink_set_option.html">
            <span class="function">BPEL.BPEL.plink_set_option</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">script</span> varchar</span>, 
	<span class="paramdef">in <span class="parameter">plink</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">opt</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">val</span> any</span>);
      </div>
    </div>
    <p>set value of a partner link option</p>



<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_import_script" />
        <span class="funcdef">
      <a href="fn_bpel_import_script.html">
            <span class="function">BPEL.BPEL.import_script</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">base_uri</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">base_name</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">scp_id</span> int</span>);
      </div>
    </div>
    <p>Import a new BPEL process</p>


  <br />
  
      <a name="xpathbpelfunctions" />
    <h3>15.15.10. BPEL XPath Functions</h3>


<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_getVariableData" />
        <span class="funcdef">
      <a href="fn_bpel_get_var.html">
            <span class="function">BPEL.BPEL.getVariableData</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">var_name</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">part</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">query</span> varchar</span>);
      </div>
    </div>
    <p>gets BPEL variable data within &lt;bpelv:exec binding=&quot;SQL&quot;&gt; activity</p>



<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="fproto_setVariableData" />
        <span class="funcdef">
      <a href="fn_bpel_set_var.html">
            <span class="function">BPEL.BPEL.setVariableData</span>
      </a>
        </span>
        (<span class="paramdef">in <span class="parameter">var_name</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">value</span> any</span>, 
        <span class="paramdef">in <span class="parameter">part</span> varchar</span>, 
        <span class="paramdef">in <span class="parameter">query</span> varchar</span>);
      </div>
    </div>
    <p>sets BPEL variable data within code invoked from &lt;bpelv:exec binding=&quot;SQL&quot;&gt; activity</p>




<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="xpf_proto_processXQuery" />
        <span class="funcdef">any <a href="xpf_processXQuery.html">
            <span class="function">processXQuery</span>
          </a>
        </span>
	(<span class="paramdef">
          <span class="parameter">module_uri</span> string</span>, 
	<span class="paramdefoptional">[<span class="optional">context</span> entity]</span>, 
	<span class="paramdefoptional">[<span class="optional">index</span> integer]</span>, 
	<span class="paramdefoptional">[<span class="optional">param1_name</span> string]</span>, 
	<span class="paramdefoptional">[<span class="optional">param1_value</span> any]</span>, 
	...
	<span class="paramdefoptional">[<span class="optional">paramN_name</span> string]</span>, 
	<span class="paramdefoptional">[<span class="optional">paramN_value</span> any]</span>);
      </div>
    </div>
    <p>Calls an XQuery module from XPath expression, e.g. from some XSLT or BPEL code.</p>





<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="xpf_proto_processXSLT" />
        <span class="funcdef">entity <a href="xpf_processXSLT.html">
            <span class="function">processXSLT</span>
          </a>
        </span>
	(<span class="paramdef">
          <span class="parameter">stylesheet_uri</span> string</span>, 
	<span class="paramdefoptional">[<span class="optional">source</span> entity]</span>, 
	<span class="paramdefoptional">[<span class="optional">param1_name</span> string]</span>, 
	<span class="paramdefoptional">[<span class="optional">param1_value</span> any]</span>, 
	...
	<span class="paramdefoptional">[<span class="optional">paramN_name</span> string]</span>, 
	<span class="paramdefoptional">[<span class="optional">paramN_value</span> any]</span>);
      </div>
    </div>
    <p>Applies stylesheet to given XML entity and returns the result.</p>



<div class="funcsynopsis">
    
      <div class="funcsynopsis">
        <a name="xpf_proto_processXSQL" />
        <span class="funcdef">entity <a href="xpf_processXSQL.html">
            <span class="function">processXSQL</span>
          </a>
        </span>
	(<span class="paramdef">
          <span class="parameter">xsql_page_uri</span> string</span>);
      </div>
    </div>
    <p>Executes XSQL page and returns the result.</p>

  <br />
  
    <a name="bpeltables" />
    <h3>15.15.11. Tables</h3>
    
    <p>BPEL Engine Tables</p>
    <div>
      <pre class="programlisting">
	
-- Scripts table, keeps one record per version
create table BPEL.BPEL.script (
	bs_id integer identity, 	-- unique id identifying the process
	bs_uri varchar,			-- obsoleted: script source URI
	bs_name varchar,		-- process name, all versions have same name
	bs_state int, 			-- 0 on, current version, 1 obsolete, 2 edit mode
	bs_date	datetime,		-- date of registration
	bs_audit int default 0, 	-- audit flag : 1 on, 0 off
	bs_debug int default 0,		-- debug flag
	bs_version int default 0,	-- process version
	bs_parent_id int default null,	-- fk to bs_id of previous process version
	bs_first_node_id int,  		-- the first node id in the graph
	bs_pickup_bf varbinary default &#39;\x0&#39;,	-- bitmask for resume nodes
	bs_act_num	int, 		-- stores the total number of activities
	bs_lpath	varchar default null, -- virtual directory

	-- process statistics
	bs_n_completed int default 0,
	bs_n_errors int default 0,
	bs_n_create int default 0,
	bs_cum_wait int default 0,
	primary key (bs_id));



-- BPEL and WSDL sources
create table BPEL..script_source
	(
	 bsrc_script_id int, -- script id, fk to bs_id of scripts table.
	 bsrc_role varchar,  -- one of bpel, bpel-ext, wsdl, deploy, partner-1... partner-n
	 bsrc_text long xml, -- source text
	 bsrc_url varchar,   -- if this comes from an uri
	 bsrc_temp varchar,  -- contains the namespaces info
	 primary key (bsrc_script_id, bsrc_role)
)
;



-- Process instances
create table BPEL.BPEL.instance (
	bi_id int identity,   		-- global immutable id of instance
	bi_script int,  		-- fk to bs_id from BPEL.BPEL.script
	bi_scope_no int default 0,  	-- sequence counter for scope numbers in instance
	bi_state int default 0,
		-- 0, started
		-- 1, suspended (wait for signal)
		-- 2, finished
		-- 3, aborted
	bi_error any,			-- error
	bi_lerror_handled int,
	bi_last_act	datetime,	-- last activity execution
	bi_started	datetime,	-- start time
	bi_init_oper	varchar,	-- operation that made the instance
	bi_wsa		long xml,	-- WS-Addressing headers
	bi_activities_bf varbinary default &#39;\x0\x0&#39;, -- bitmask for each activity is completed or not
	bi_link_status_bf varbinary default &#39;\x0\x0&#39;, -- bitmask for link status
	bi_prefix_info varchar default &#39;&#39;, -- xpath prefix string
	primary key (bi_id));



-- Initial values (URL etc.) for partner links
create table BPEL.BPEL.partner_link_init (
	bpl_script int, 	-- script instance id
	bpl_name varchar,	-- partner link name
	bpl_partner any,  	-- url, end point etc serialized
	bpl_role varchar,
	bpl_myrole varchar,
	bpl_type varchar,
	bpl_endpoint varchar,	-- partner service endpoint URL
	bpl_backup_endpoint varchar,
	bpl_wsdl_uri varchar,
	bpl_debug int default 0,-- debug flag
	bpl_opts long xml,	-- partner link options (WS-Security, WS-RM etc.)
	primary key (bpl_script,bpl_name));



-- Runtime values for partner links (run time copy of partner_link_init table)
create table BPEL..partner_link (
	pl_inst int, 		-- instance id
	pl_name varchar, 	-- partner link name
	pl_scope_inst int, 	-- scope instance id
	pl_role int, 		-- flag 0 - myRole, 1 - partnerRole
	pl_endpoint varchar, 	-- current URL to the partner service
	pl_backup_endpoint varchar, -- second URL to the service for connection error
	pl_debug int default 0,	-- debug flag
	pl_opts long xml,	-- partner link options (WS-Security, WS-RM etc.)
	primary key (pl_inst, pl_name, pl_scope_inst, pl_role));



-- Script compilation
create table BPEL.BPEL.graph (
	bg_script_id int,  	-- FK to bs_id of BPEL.BPEL.script
	bg_node_id int , 	-- running id in the script, referenced from BPEL.BPEL.waits etc.
	bg_activity BPEL.BPEL.activity, -- UDT representing activity
	bg_childs any,
	bg_parent int,
        bg_src_id varchar,	-- internal use
	primary key (bg_script_id, bg_node_id));



-- Receive activities waiting for incoming message
create table BPEL.BPEL.wait (
	bw_uid varchar,
	bw_instance integer,  -- instance id
	bw_script varchar,    -- FK reference to bs_name of script table
	bw_script_id int,     -- FK reference to bs_id of script table
	bw_node int,	      -- FK reference to bg_node_id of the graph table
	bw_scope  int,
	bw_partner_link varchar, -- the party from which instance waiting a message
	bw_port varchar,  	 -- the name of the operation which instance wait to receive
	bw_deadline datetime,
	bw_message long varchar default null, -- if instance is occupied and message is already arrived
	bw_state int default 0,		      -- flag that bw_message is not null (0 or 1)
	bw_correlation_exp varchar, 	      -- XPath expression for computing the correlation value from message
	bw_expected_value long varbinary,     -- value of the expected correlation
	bw_message_type int default 0,	      -- where to expect the data : 0 - SOAP:Body 1 - SOAP:Header
	bw_start_date datetime,
	primary key (bw_instance, bw_node));



-- Messages which have been arrived but not correlated yet
create table BPEL.BPEL.queue (
	bq_id int identity,	-- unique id
	bq_script int,		-- FK references bs_id from the script table
	bq_ts timestamp,
	bq_state int,		-- state of the Queue item; 0 - not processed
	bq_endpoint varchar,	-- not used
	bq_op varchar,		-- Operation name
	bq_mid varchar,		-- mot used
	bq_message long varchar, -- The incoming message text
	bq_header long varchar,  -- SOAP:Header
	primary key (bq_op, bq_ts)
	);



-- Initial values for SOAP Messages and XMLSchema types
create table BPEL..types_init (
	vi_script int,	   -- FK reference to bs_id to the script table
	vi_name   varchar, -- message name, element name etc.
	vi_type   int, 	   -- 0 - message, 1 - element, 2 - XMLSchema type
	vi_value  long xml,-- Initial value
	primary key (vi_script, vi_name, vi_type)
)
;



-- Matching XPath expressions for the SOAP message parts
create table BPEL.BPEL.message_parts
	(
	mp_script int,	    -- FK reference to bs_id to the script table
	mp_message varchar, -- message name
	mp_part varchar,    -- part name
	mp_xp   varchar,    -- location XPath expression
	primary key (mp_script, mp_message, mp_part)
	)
;



-- Operations which are invoked by process (used in invoke activities)
create table BPEL.BPEL.remote_operation (
	ro_script int,		-- FK reference to bs_id to the script table
	ro_partner_link varchar,-- name of the partner link
	ro_role varchar,	-- not used
	ro_operation varchar,	-- operation name
	ro_port_type varchar,	-- port type
	ro_input varchar,	-- input message name
	ro_output varchar,	-- output message name
	ro_endpoint_uri varchar,-- not used
	ro_style int,		-- messages encoding style : 1 - literal, 0 - RPC like
	ro_action varchar default &#39;&#39;, -- SOAP Action value
	ro_target_namespace varchar,  -- for RPC encoding the namespace to be used for wrapper elements
	ro_use_wsa int default 0, -- WS-Addressing capabilities flag
	ro_reply_service varchar, -- for one-way operations: reply service name
	ro_reply_port varchar,    -- for one-way operations: reply port type
	primary key (ro_script, ro_partner_link, ro_operation)
)
;



-- Operations which process defines (can receive and reply)
create table BPEL.BPEL.operation (
	bo_script int,		-- FK reference to bs_id to the script table
	bo_name	varchar,	-- operation name
	bo_action varchar,	-- SOAP Action value
	bo_port_type	varchar,-- port type
	bo_partner_link varchar,-- name of the partner link
	bo_input	varchar,-- input message name
	bo_input_xp	varchar,-- XPath expression to match the input message
	bo_small_input	varchar,-- not used
	bo_output	varchar,-- output message name
	bo_style	int default 0,-- messages encoding style : 1 - literal, 0 - RPC like
	bo_init		int,	-- process instantiation flag: 1 - can make new instances
	primary key (bo_script, bo_name, bo_partner_link)
);



-- Predefined endpoint URLs for partner links
create table BPEL.BPEL.partner_link_conf (
	plc_name	varchar,
	plc_endpoint	varchar,
	primary key (plc_name)
)
;



-- Properties
create table BPEL.BPEL.property
(
  bpr_script int, 	-- FK reference to bs_id to the script table
  bpr_name varchar,	-- property name
  bpr_type varchar,	-- property type
  primary key (bpr_script, bpr_name)
)
;



-- Aliases
create table BPEL.BPEL.property_alias (
	pa_script	int,		-- FK reference to bs_id to the script table
	pa_prop_id	int identity,
	pa_prop_name	varchar,	-- property name
	pa_message	varchar,	-- message name
	pa_part		varchar,	-- part name
	pa_query	varchar,	-- XPath query to set the property value
	pa_type		varchar,
	primary key (pa_script, pa_prop_name, pa_message))
;



-- Correlation properties
create table BPEL.BPEL.correlation_props (
	cpp_id 		int identity (start with 1),
	cpp_script	int,		-- FK reference to bs_id to the script table
	cpp_corr	varchar,	-- correlation name
	cpp_prop_name	varchar,	-- property name
	primary key (cpp_id, cpp_script, cpp_corr, cpp_prop_name))
;



-- Variables
create table BPEL..variables (
	v_inst 		int,		-- instance id, FK reference bi_id of the instance table
	v_scope_inst   	int,		-- scope instance id; different than 0 for compensation scope
	v_name 		varchar,	-- variable name
	v_type 		varchar,	-- variable type
	v_s1_value	any, 		-- string, numeric
	v_s2_value	varchar, 	-- XML entities
	v_b1_value	long varchar,	-- long strings
	v_b2_value	long varchar, 	-- XML entities
	primary key (v_inst, v_scope_inst, v_name))
;



-- Links
create table BPEL..links
	(
	  bl_script int,	-- FK reference to bs_id to the script table
	  bl_name   varchar,	-- link name
	  bl_act_id int,	-- corresponding link activity bit number
	  primary key (bl_act_id, bl_script)
	)
;



-- Compensation scopes
create table BPEL..compensation_scope
	(tc_inst int,
	 tc_seq	 int identity (start with 1),
	 tc_scopes long varbinary,
	 tc_head_node int,
	 tc_head_node_bit int,
	 tc_compensating_from int default null,
	 primary key (tc_inst, tc_seq)
	)
;



-- Messages are correlated via WS-Addressing
create table BPEL..wsa_messages
	(
	wa_inst int,
	wa_pl	varchar,
	wa_mid  varchar,
	primary key (wa_inst, wa_pl, wa_mid)
	)
;



create table BPEL..lock
	(
	lck int primary key
	)
;



-- Accepted connections which are waiting for reply
create table BPEL..reply_wait
	(
	rw_inst int,
	rw_id int, -- identity (start with 1),
	rw_partner varchar,
	rw_port varchar,
	rw_operation varchar,
	rw_query varchar,
	rw_expect varchar,
	rw_started datetime,
	primary key (rw_inst, rw_id)
	)
;



-- Registered alarm events
create table BPEL..time_wait
	(
	  tw_inst 	int,
	  tw_node 	int,
	  tw_scope_inst int,
	  tw_script	varchar,
	  tw_script_id	int,
	  tw_sec  	int,
	  tw_until 	datetime,
	  primary key (tw_inst, tw_node)
	)
;



-- BPEL message debugging queue
create table BPEL..dbg_message (
	bdm_text long varchar,		-- message text
	bdm_id int identity (start with 1),
	bdm_ts datetime,
	bdm_inout int, 			-- 1 for in, 0 for out
	bdm_sender_inst int, 		-- instance id of sender if outbound message
	bdm_receiver int, 		-- if inbound, inst id of receiving inst
	bdm_plink varchar, 		-- name of partner link in the script in question
	bdm_recipient varchar, 		-- partner link value for outbound message, URL.
	bdm_activity int, 		-- activity id of activity that either sent the message or would receive the message in the sender/receiver instance.
	bdm_oper varchar,		-- operation name
	bdm_script int,			-- process id, FK reference bs_id from script table
	bdm_action varchar,		-- SOAP Action value
	bdm_conn int,			-- client connection id
	primary key (bdm_id)
)
;



-- BPEL engine configuration
create table BPEL..configuration (
	conf_name	varchar not null,
	conf_desc 	varchar,
	conf_value	any, -- not blob
	conf_long_value	long varchar,
	primary key (conf_name)
)
;



create table BPEL.BPEL.op_stat
	(
	 bos_process int,
	 bos_plink varchar,
	 bos_op varchar,
	 bos_n_invokes int default 0,
	 bos_n_receives int default 0,
	 bos_cum_wait numeric default 0, -- milliseconds total time wait at the partner link/operation
	 bos_data_in numeric default 0,
	 bos_data_out numeric default 0,
	 bos_n_errors int default 0,
	 primary key (bos_process, bos_plink, bos_op)
)
;



create table BPEL.BPEL.error_log
	(
	 bel_ts timestamp,
	 bel_seq int identity,
	 bel_level int, -- bel_level is 1. fatal 2. network, 3 instance.
	 bel_notice_sent datetime,  -- time the email was sent, null if none
	 bel_text varchar,
	 primary key (bel_ts, bel_seq)
)
;



create table BPEL.BPEL.hosted_classes
	(
	 hc_script	int,
	 hc_type	varchar default &#39;java&#39;,
	 hc_name	varchar,
	 hc_text	long varbinary, -- compiled class
	 hc_path	varchar, -- path to class if it is stored in file system
	 hc_load_method	varchar,
	 primary key (hc_script, hc_type,  hc_name)
)
;




	
    </pre>
    </div>
  <br />
  
      <a name="bpelerrors" />
    <h3>15.15.12. Errors</h3>
      <p>During the BPEL process execution we may consider
	  following types of errors:
      </p>
	  <ul>
	      <li>Server failure - This means that the server as a whole
		  has stopped operations and requires manual intervention.
		  This is the case for: out of disk or database corruption.
	      </li>
	      <li>Network - This category applies to possibly transient
		  conditions of not being able to contact partners.
		  The server remains in operation for unaffected partners.</li>
	      <li>Process Instance - This category applies to process
		  instances getting an unhandled error condition.
		  The process instance is out of service until the condition
		  is resolved. This may indicate a bug in the process itself
		  or a component used by it.</li>
	  </ul>
	  <p>These errors will be logged in the file system (bpel_audit/server_log.txt) .
	      If logging fails, an email is sent to the operator. The errors are also logged
	      in the &#39;BPEL.BPEL.error_log&#39; table so as to avoid repeatedly sending the same message.
	  </p>
       <p>During uploading the BPEL process we may consider
	  following types of errors:
      </p>
          <ul>
	      <li>bpel.xml file contains non-absolute paths and must be
                  changed to absolute in order the uploading to be successful.
                  This is in case user uses import_script api.
	      </li>
              <li>wsdl file contains non-absolute paths at importing other wsdl file or xsd and must be
                  changed to absolute in order the uploading to be successful.
                  This is in case user uses upload process by choosing url/file for bpel and wsdl.
	      </li>
              <li>process name already exists. This means there is already uploaded a process with the given name.</li>
              <li>at least one activity &quot;receive&quot; or &quot;pick&quot; must be declared at script source.
                 Otherwise will be reported error this condition to be accomplished.
	      </li>
	  </ul>
    <a name="bpelerrors_conn" />
    <h4>15.15.12.1. Connection Errors</h4>
      <p>The communication error can be caught  by explicit fault
	handler in the script. In this case the &lt;catch&gt; handler must
	  catch   the fault &quot;bpws:communicationFault&quot;: </p>
      <div>
      <pre class="programlisting">
  &lt;catch faultName=&quot;bpws:communicationFault&quot; faultVariable=&quot;error&quot;&gt;
   ...
  &lt;/catch&gt;
	</pre>
    </div>
      <p>The error variable &quot;error&quot; will contain the following
	fault structure: </p>
      <div>
      <pre class="programlisting">
 &lt;comFault sqlState=&quot;xxxxx&quot; message=&quot;text-of-message&quot;
   partnerLink=&quot;plinkname&quot; activity=&quot;name of activity&quot; partnerURI=&quot;uri of
partner&quot;&gt;
   &lt;message&gt;-- copy of the message being sent when fault occurred -- &lt;/message&gt;
 &lt;/comFault&gt;
	</pre>
    </div>
      <p>which can be used for reporting, recovery etc... The
	&quot;sqlState&quot; attribute contains SQL error state and the
	&quot;message&quot; stores the first line of SQL error message. </p>
      <p>If the script does not handle this fault, the script will
	be frozen until explicit or implicit restart. </p>
      <p>Here is an example of explicit communication handling:
      </p>
      <div>
      <pre class="programlisting">
&lt;process xmlns:tns=&quot;urn:echo:echoService&quot; xmlns=&quot;http://schemas.xmlsoap.org/ws/2003/03/business-process/&quot; name=&quot;faultHTCLI&quot; targetNamespace=&quot;urn:echo:echoService&quot;  xmlns:bpelv=&quot;http://www.openlinksw.com/virtuoso/bpel&quot;&gt;
  &lt;partnerLinks&gt;
    &lt;partnerLink name=&quot;caller&quot; partnerLinkType=&quot;tns:echoSLT&quot;/&gt;
    &lt;partnerLink name=&quot;test&quot; partnerLinkType=&quot;tns:testSLT&quot; partnerRole=&quot;service&quot;/&gt;
  &lt;/partnerLinks&gt;
  &lt;variables&gt;
    &lt;variable name=&quot;request&quot; messageType=&quot;tns:StringMessageType&quot;/&gt;
    &lt;variable name=&quot;res&quot; messageType=&quot;tns:StringMessageType&quot;/&gt;
    &lt;variable name=&quot;n_tries&quot; messageType=&quot;tns:IntMessageType&quot;/&gt;
  &lt;/variables&gt;
  &lt;sequence name=&quot;EchoSequence&quot;&gt;
    &lt;assign&gt;
      &lt;copy&gt;
        &lt;from expression=&quot;3&quot;/&gt;
	&lt;to variable=&quot;n_tries&quot; part=&quot;value&quot; query=&quot;/value&quot;/&gt;
      &lt;/copy&gt;
    &lt;/assign&gt;
    &lt;receive partnerLink=&quot;caller&quot; portType=&quot;tns:echoPT&quot; operation=&quot;echo&quot; variable=&quot;request&quot; createInstance=&quot;yes&quot; name=&quot;EchoReceive&quot;/&gt;
    &lt;while condition=&quot;getVariableData (&#39;n_tries&#39;, &#39;value&#39;, &#39;/value&#39;)
	   &amp;gt; 0&quot;&gt;
      &lt;sequence&gt;
	&lt;scope&gt;
	  &lt;faultHandlers&gt;
	    &lt;catch faultName=&quot;bpws:communicationFault&quot; faultVariable=&quot;error&quot;&gt;
	      &lt;sequence&gt;
		&lt;bpelv:exec binding=&quot;SQL&quot;&gt;
		  dbg_obj_print (BPEL.BPEL.getVariableData (&#39;error&#39;));
		  dbg_obj_print (BPEL.BPEL.getVariableData (&#39;n_tries&#39;));
		&lt;/bpelv:exec&gt;
		&lt;assign&gt;
		  &lt;copy&gt;
		    &lt;from variable=&quot;error&quot; query=&quot;/comFault/@sqlState&quot;/&gt;
		    &lt;to variable=&quot;res&quot; part=&quot;echoString&quot; query=&quot;/echoString&quot;/&gt;
		  &lt;/copy&gt;
		  &lt;copy&gt;
		    &lt;from expression=&quot;getVariableData (&#39;n_tries&#39;,
			  &#39;value&#39;, &#39;/value&#39;) - 1&quot;/&gt;
		    &lt;to variable=&quot;n_tries&quot; part=&quot;value&quot; query=&quot;/value&quot;/&gt;
		  &lt;/copy&gt;
		&lt;/assign&gt;
		&lt;wait for=&quot;PT10S&quot;/&gt;
	      &lt;/sequence&gt;
	    &lt;/catch&gt;
	    &lt;catchAll&gt;
	      &lt;empty/&gt;
	    &lt;/catchAll&gt;
	  &lt;/faultHandlers&gt;
	  &lt;sequence&gt;
	    &lt;invoke partnerLink=&quot;test&quot; portType=&quot;tns:SOAPPortType&quot; operation=&quot;test&quot; inputVariable=&quot;request&quot; outputVariable=&quot;res&quot;/&gt;
	    &lt;assign&gt;
	      &lt;copy&gt;
		&lt;from expression=&quot;0&quot;/&gt;
		&lt;to variable=&quot;n_tries&quot; part=&quot;value&quot; query=&quot;/value&quot;/&gt;
	      &lt;/copy&gt;
	    &lt;/assign&gt;
	  &lt;/sequence&gt;
	&lt;/scope&gt;
      &lt;/sequence&gt;
    &lt;/while&gt;
    &lt;reply partnerLink=&quot;caller&quot; portType=&quot;tns:echoPT&quot; operation=&quot;echo&quot; variable=&quot;res&quot; name=&quot;EchoReply&quot;/&gt;
  &lt;/sequence&gt;
&lt;/process&gt;
	</pre>
    </div>
      <p>In this example the process in a case of communication
	exception makes 3 reconnection  retries to the remote
	service. Each reconnection is made after waiting 10 seconds.
      </p>
    <br />
    <a name="bpelerrors_deadlock" />
    <h4>15.15.12.2. Deadlock Errors</h4>
      <p> During concurrent execution of several BPEL scripts
	deadlock conditions can be signalled. That is why Virtuoso BPEL
	engine contains implicit deadlock detection and retry
	capability. When the deadlock is detected, the engine tries to
	wait some time, and retry the transaction. If the number of
	retries exceeds some maximum number the script execution
	will be aborted and mail will be sent to the operator with
	an appropriate message.</p>
      <p>The time to wait  before retry and the maximum number of retries can be configured on
	the configuration page of the administration UI.</p>
    <br />
  <br />
  
    <a name="bpelsampl" />
    <h3>15.15.13. Samples</h3>
    
    <p>Simple echo script</p>
    <div>
      <pre class="programlisting">
&lt;process name=&quot;echo&quot; targetNamespace=&quot;http://temp.uri&quot; xmlns:tns=&quot;http://temp.uri&quot;
    xmlns=&quot;http://schemas.xmlsoap.org/ws/2003/03/business-process/&quot;&gt;

    &lt;partnerLinks&gt;
	&lt;partnerLink name=&quot;caller&quot; partnerLinkType=&quot;tns:echoService&quot;/&gt;
    &lt;/partnerLinks&gt;

    &lt;variables&gt;
	&lt;variable name=&quot;request&quot; messageType=&quot;tns:StringMessageType&quot;/&gt;
    &lt;/variables&gt;

    &lt;sequence name=&quot;EchoSequence&quot;&gt;
	&lt;receive partnerLink=&quot;caller&quot; portType=&quot;tns:echoPort&quot;
	    operation=&quot;echo&quot; variable=&quot;request&quot;
	    createInstance=&quot;yes&quot; name=&quot;EchoReceive&quot;/&gt;
	&lt;reply partnerLink=&quot;caller&quot; portType=&quot;tns:echoPort&quot;
	    operation=&quot;echo&quot; variable=&quot;request&quot; name=&quot;EchoReply&quot;/&gt;
    &lt;/sequence&gt;

&lt;/process&gt;
	</pre>
    </div>
    <p>... and corresponding WSDL</p>
    <div>
      <pre class="programlisting">
&lt;definitions targetNamespace=&quot;http://temp.uri&quot; xmlns:tns=&quot;http://temp.uri&quot;
             xmlns:pl=&quot;http://schemas.xmlsoap.org/ws/2003/05/partner-link/&quot;
	     xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
	     xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;&gt;

   &lt;message name=&quot;StringMessageType&quot;&gt;
      &lt;part name=&quot;echoString&quot; type=&quot;xsd:string&quot;/&gt;
   &lt;/message&gt;

   &lt;portType name=&quot;echoPort&quot;&gt;
      &lt;operation name=&quot;echo&quot;&gt;
         &lt;input message=&quot;tns:StringMessageType&quot;/&gt;
         &lt;output message=&quot;tns:StringMessageType&quot;/&gt;
      &lt;/operation&gt;
   &lt;/portType&gt;

   &lt;pl:partnerLinkType name=&quot;echoService&quot;&gt;
     &lt;pl:role name=&quot;svc&quot;&gt;
       &lt;pl:portType name=&quot;tns:echoPort&quot;/&gt;
     &lt;/pl:role&gt;
   &lt;/pl:partnerLinkType&gt;

&lt;/definitions&gt;
	</pre>
    </div>
  <p>Invoking Echo Service</p>
  <div>
      <pre class="programlisting">
    SQL&gt;select xpath_eval (&#39;/echoResponse/echoString/text()&#39;,
	xml_tree_doc (
		DB.DBA.soap_client (
		url=&gt;sprintf (&#39;http://localhost:%s/BPELGUI/bpel.vsp?script=file://echo/echo.bpel&#39;,server_http_port()),
		operation=&gt;&#39;echo&#39;,
		soap_action=&gt;&#39;echo&#39;,
		parameters=&gt; vector (&#39;par&#39;, xtree_doc (&#39;hello world&#39;)))
		));
        callret
        VARCHAR
         _______________________________________________________________________________

         hello world

         1 Rows. -- 330 msec.
  </pre>
    </div>
  <a name="bpelsampl_functions" />
    <h4>15.15.13.1. BPEL Functions</h4>
      <p>getVariableData</p>
      <div>
      <pre class="programlisting">
      ...
      &lt;assign name=&quot;assignResult&quot;&gt;
        &lt;copy&gt;
          &lt;from expression=&quot;concat( &#39;Hello &#39;, bpws:getVariableData(&#39;input&#39;, &#39;payload&#39;, &#39;/tns:echovirtRequest/tns:name&#39;), &#39; &#39;, bpws:getVariableData(&#39;input&#39;, &#39;payload&#39;, &#39;/tns:echovirtRequest/tns:fname&#39;))&quot;/&gt;
          &lt;to variable=&quot;output&quot; part=&quot;payload&quot; query=&quot;/tns:echovirtResponse/tns:result&quot;/&gt;
        &lt;/copy&gt;
      &lt;/assign&gt;
      ...
      </pre>
    </div>
      <p>count</p>
      <div>
      <pre class="programlisting">
      ...
      &lt;assign name=&quot;assignResult&quot;&gt;
        &lt;copy&gt;
          &lt;from part=&quot;payload&quot; variable=&quot;input&quot; query=&quot;count(//lines/line)&quot;/&gt;
          &lt;to variable=&quot;count&quot;/&gt;
        &lt;/copy&gt;
      &lt;/assign&gt;
      ...
      </pre>
    </div>
    <br />
  <div class="tip">
  <div class="tiptitle">See Also: Reference Material in the Tutorial:</div>
   <p>
       <a href="/tutorial/services/bp_s_1/bp_s_1.vsp">BP-S-1 Loan Flow demo</a>
   </p>
  </div>
  <div class="tip">
  <div class="tiptitle">See Also: Reference Material in the BPELDemo tutorials:</div>
   <p>
      BPEL4WS VAD package must be installed in order to view these tutorials.
   </p>
   <p>
       <a href="/BPELDemo/">BPELDemo</a>
   </p>
  </div>
  <br />
  
    <a name="bpelrefs" />
    <h3>15.15.14. References</h3>
   <p>
       <a href="http://www-106.ibm.com/developerworks/library/ws-bpel/">BPEL4WS specification</a>
   </p>
   <p>
       <a href="http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnglobspec/html/ws-addressing.asp">WS-Addressing</a>
   </p>
   <p>
       <a href="http://www.w3.org/TR/wsdl">WSDL specification</a>
   </p>
   <p>
       <a href="http://www.w3.org/TR/soap/">SOAP specification</a>
   </p>
   <p>
       <a href="http://www.w3.org/TR/xpath/">XPath specification</a>
   </p>
  <br />
  
    <a name="bpelvadinstall" />
    <h3>15.15.15. BPEL4WS VAD Package installation</h3>
      <a name="bpelvadinstall_conductor" />
    <h4>15.15.15.1. Using Conductor</h4>
        <ul>
	  <li>
	    Step 1. Download BPEL4WS VAD and copy it to a local directory.
	  </li>
	  <li>
	    Step 2. Go to Conductor UI: http://host:port/conductor/
	  </li>
	  <li>
	    Step 3. Login into the Virtuoso Conductor using the admin account.
	  </li>
          <li>
	    Step 4. Select Systems Admin-&gt;Packages Tab.
	  </li>
          <li>
	    Step 5. Under the Install Packaged, section of the UI is a list of VAD packages.
            If this is the first time you have installed a VAD package you will only see the Virtuoso Conductor.
            Directly under this list is the option Install a Package.  You can either enter or browse to the
            location of the directory of the BPEL4WS package or enter a DAV location.
	  </li>
          <li>
	    Step 6. Once you have provided the location, select Proceed to upload the package.
	  </li>
        </ul>
    <br />
    <a name="bpelvadinstall_isql" />
    <h4>15.15.15.2. Using ISQL</h4>
      <div>
      <pre class="programlisting">
       SQL&gt;VAD_INSTALL(&#39;bpel4ws.vad&#39;,0);
        SQL_STATE  SQL_MESSAGE
        VARCHAR  VARCHAR
        _______________________________________________________________________________

        00000    GUI is accessible via http://host:port/BPELGUI
        00000    Quick Start is available from http://host:port/BPELGUI/start.vsp
        00000    No errors detected, installation complete.
        00000    Now making a final checkpoint.
        00000    Final checkpoint is made.
        00000    SUCCESS

        7 Rows. -- 5438 msec.
       </pre>
    </div>
    <br />
  <br />
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="vsmx.html" title="Testing Web Published Web Services">Previous</a>
          <br />Testing Web Published Web Services</td>
     <td align="center" width="34%">
          <a href="webservices.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="xsql.html" title="XSQL">Next</a>
          <br />XSQL</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>