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:
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
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
Simple but so useful!
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"> <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> <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/";
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)
Simple but so useful!