Custom XPath in OSB 11g

There is already a documentation available for this cool new feature in OSB 11g to create custom XPath functions that can be used from the OEPE IDE or even from the Service bus console.

For the ones who have a touch time to understand the Oracle documentation, here is a brief tutorial.

Please refer to the Oracle Document here for the detailed steps:

http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/custom_xpath.htm#CBADFJEG

I would start of by creating my own xml for my own custom function. I would name it custom-osb-xpath.xml with a corresponding .properties file associated with it. Here are the contents:

custom-osb-xpath.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<xpf:xpathFunctions xmlns:xpf=”http://www.bea.com/wli/sb/xpath/config”&gt;
<xpf:category id=”%CUSTOM_FUNCTIONS%”>
<xpf:function>
<xpf:name>concatStrings</xpf:name>
<xpf:comment>%FUNC_CONC_COMMENT%</xpf:comment>
<xpf:namespaceURI>http://www.dell.com/alsb/custom/xpath/xpath-functions</xpf:namespaceURI&gt;
<xpf:className>com.caterpillar.alsb.custom.xpath.StringConcat</xpf:className>
<xpf:method>java.lang.String concatString(java.lang.String, java.lang.String)</xpf:method>
<xpf:isDeterministic>false</xpf:isDeterministic>
<xpf:scope>Pipeline</xpf:scope>
<xpf:scope>SplitJoin</xpf:scope>
</xpf:function>
</xpf:category>
</xpf:xpathFunctions>

custom-osb-xpath.properties

%CUSTOM_FUNCTIONS%=Custom Service Bus Functions
%FUNC_CONC_COMMENT%=Returns a concatenated string based on the input strings. E.g. fn-bea:concatStrings($string1 as xs:string, $string2 as xs:string )

Place these files in OSB_ORACLE_HOME/config/xpath-functions directory of the OSB installation.

Now we would create a sample java class to concatenate two strings

package com.caterpillar.alsb.custom.xpath;

import java.lang.String;

public class StringConcat {

public static java.lang.String concatString(String stringa, String stringb)
{
String concatedStr= new String(stringa);
return concatedStr.concat(stringb);
}

}

Thats all we need. We are good to go now. Restart the OSB server or the Eclipse IDE. On booting them up we would start to see these custom functions added.

Here is a sample Xquery i created to use this custom XPath funtion
declare namespace xf = “http://tempuri.org/CommonServices/Common/Monitoring/XQ/ConcatStrings/&#8221;;

declare function xf:ConcatStrings($string1 as xs:string,
$string2 as xs:string)
as xs:string {
xpat8i:concatStrings($string1,$string2)
};

declare variable $string1 as xs:string external;
declare variable $string2 as xs:string external;

xf:ConcatStrings($string1,
$string2)

CustomXPath

Simple but so useful!

2 thoughts on “Custom XPath in OSB 11g

  1. Pingback: Custom XPath Functions in OSB 11g to Lookup Shared DVMs « Oracle Technologies Premier

  2. Pingback: Lookup Shared DVM in OSB | Oracle Technologies Premier | jmmate JavaBlog

If you have any comments, suggestions or feedback about the post, please feel free to type it here and I will do my best to address them asap

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s