Wednesday, September 10, 2008

more on XPath BPEL function

Today I got a query on XPath BPEL functions . For exception handling even though the function getFaultAsString() and getFaultName( ) is there Jdev is showing error when he is trying to use it. It is a valid doubt. Jdeveloper is not fully supporting all the XPath BPEL functions available to BPEL processes.

Most of these XPath BPEL functions have the namespace registered under “ “ and prefix as “ora” .

So to make it work open your .bpel file in source mode and add the namespace with the prefix you want to use

For eg:

<process name="HelloWorld" targetNamespace="" xmlns:ora=”

…….. />

In your operation insert the expression in the following syntax ora:getFaultAsString().

To know what all functions are available in your environment look into xpath-functions.xml under ORACLE_HOME/domains/default/config directory.

It is not mandatory all XPath BPEL functions will have the same namespace. I will explain where namespace can be obtained for a particular function below.

The getFaultAsString () function entry will look like the following. It will have the class name which will be providing the functionality. The property namespace-uri will give you the value of namespace and namespace-prefix will give you the prefix to be used while calling it in your bpel process(add entry in .bpel file)

Snippet from xpath-functions.xml

<function id="getFaultAsString">



The signature of this function is <i>ora:getFaultAsString()</i>.


<property id="namespace-uri">


<comment><![CDATA[Namespace URI for this function]]></comment>


<property id="namespace-prefix">


<comment><![CDATA[Namespace prefix for this function]]></comment>



Similarly if you have installed AIA you can use the function in the expression using the following syntax aia:getErrorMessage('errorCode', 'localeString', 'delimiter')

Snippet from xpath-functions.xml after AIA installation

<function id="getErrorMessage" arity="3">

<comment><![CDATA[This function will lookup the error message resource bundle and

return a localized string for the input errorCode.


The signature of the function is <i>

aia:getErrorMessage('errorCode', 'localeString', 'delimiter')</i>.

The arguments are: <ol type="1"> <li>errorCode - the error code.

<li>localeString - delimiter locale string <li>delimiter - </ol>]]></comment>


<property id="namespace-uri"> <value></value>

<comment><![CDATA[Namespace URI for this function]]></comment>


<property id="namespace-prefix">


<comment><![CDATA[Namespace prefix for this function]]></comment>



Cool right. When you need a custom functionality for example the AIA Excpetion handling functions implement the functionality in java.

Your Custom class should implement the interface and implement the method named call(context, args). The signature of this method is as follows:

Object call(IXPathContext context, List args)throws XPathFunctionException;

Compile these files and then place these classes in bpel classpath and add entries to xpath-functions.xml. That is what you call a plugin.

No comments: