Importing SOA 11g standard XPath Functions into OSB 11g
Ok, so heres the problem. OSB 11g and SOA 11g XPath functions are not in Sync. So, XSLTs that were developed in SOA 10g cannot be used directly in OSB 11g. One of the strong cases for this is the migration of all ESB based artifacts to OSB artifacts.
One of the easiest ways of doing this is to take all the xpath functions that are defined in the soa-xpath-exts.jar and soa-xpath-functions-config.xml and dump em into OSB XPath config as a Custom XPath. Here are the steps:
1. Get the fabric-runtime.jar and the soa-xpath-exts.jar from %SOA_HOME%\soa\modules\oracle.soa.fabric_11.1.1
2. Get the soa-xpath-functions-config.xml from %JDEVELOPER_HOME%\jdeveloper\integration\seed\soa\configuration. This file contains a list of all the XPath functions. We wont do anything to this….just for reference.
3. Now, get the osb-built-in.xml and osb-built-in.properties files from%OSB_HOME%\config\xpath-functions. Create copies of these files. We will modify these copies to include the migrated XPath Functions.
4. Now the task is to map the XPath functions defined in soa-xpath-functions-config.xml to the copy of the osb-built-in.xml that you just built. Almost for all the XPaths the only thing that needs to be changed is <xpf:name>,<xpf:comment>,<xpf:namespaceURI>,<xpf:className> and the <xpf:method>. Rest of the elements can be safely kept as is. The mentioned five elements can be directly mapped from the soa-xpath-functions-config.xml. But note that OSB XPath functions doesnt support inner classes and there are a hell lot of inner classes in the soa-xpath-functions-config.xml. So inorder to get over this, you have to somehow get the source code of the custom xpath functions, check which method of a particular class gets called and use that in the <xpf:className> and the <xpf:method>.
5. Make sure you know the permitted java types when you specify the <xpf:method> as in the document: http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/custom_xpath.htm#CBADFJEG. Some of the methods cannot be used !!!
6. Also make sure that for each XPath defined in the copy of the osb-built-in.xml you have to specify the comments in the proeprties file as well.
7. After you are done, dump all the jars and the OSB custom XPath files into %OSB_HOME%\config\xpath-functions.
This is a lot of pain.. and it would definitely take a good 8 hours!!!
Anywayz, if you dont want to do all this re-engineering, you alternatively use the Nirvana package below 🙂 This package contains support for the XPaths listed here
Unzip the folder and copy everything to %OSB_HOME%\config\xpath-functions . Restart Weblogic and Workshop. Follow the Installation Instructions in the reference for more details.
These XPath functions have the same name as the standard SOA 10g functions, although the namespaces are different.
The usage of these functions are different for XSLT and XQuery.
- XQuery: The XPath functions listed in the table should be used alongwith the necessary namespaces. This means that you can directly drag from the Expressions window.
- XSLT: For use in XSLT expressions, the Java Method name of the custom XPath function should be used alongwith the necessary namespaces.
Note the difference in usage for the format-date XPath in XQuery and XSLT:
<Result><formatDate>dat:format-date(‘2028-08-31T05:30:54+05:30′,’yyyy.MM.dd G HH:mm:ss z’)</formatDate></Result>
<xsl:stylesheet version=“1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” xmlns:dat=“http://www.soa-utilities.com/osb/custom/xpath/utilties.xpath.extensions.DateFunctions”><xsl:template match=“/”>
<Result><formatDate><xsl:value-of select=“dat:formatDate(‘2028-08-31T05:30:54+05:30′,’yyyy.MM.dd G HH:mm:ss z’)” /></formatDate></Result>
The full list of namespaces for each XPath can be found in here.