In this post we will see that how to create user defined function to use in XSLT Mapper.
Step1:- Create Java class to write the User defined function. The below Java code will convert long value into decimal value.
package com.geo.xpath;
public class LongToNumericPrimitiveTypesExample {
public static double LongToNumericPrimitiveTypes (Long input){
Long lObj = new Long("input");
double d = lObj.doubleValue();
return d;
}
}
Step 2:- Create ext-mapper-xpath-functions-config.xml file to contain the following value
<soa-xpath-functions version="11.1.1"
xmlns="http://xmlns.oracle.com/soa/config/xpath"
xmlns:geo="http://www.oracle.com/XSL/Transform/java/com.geo.xpath.LongToNumericPrimitiveTypesExample">
<function name="geo:LongToNumericPrimitiveTypes">
<className>com.geo.xpath.LongToNumericPrimitiveTypesExample</className>
<return type="number"/>
<params>
<param name="input" type="number"/>
</params>
<desc/>
<detail>
<![CDATA[This function convert long to decimal message.]]>
</detail>
</function>
</soa-xpath-functions>
In this XML basically Java class method is defined. Put this XML inside the META-INF folder in the same java class and create a JAR file of it.
Step 3:- For creating JAR file from JDeveloper. Right Click on the Java project select New -> Deployment Profile(From option select JAR File) then name the jar file and click next. Accept the all default value and the click Finish. Now right click again on the same project and click on the deploy option and deploy that JAR Archive. It will create the JAR file on to location like JDeveloper\mywork\Application1\LongTodecimalConversion\deploy. Verify if in the created jar file META-INF folder contains the ext-mapper-xpath-functions-config.xml file.
Step 4:- Now in JDeveloper select the Tools -> Preferences -> SOA and use the Add button to select the created jar. Now restart the JDeveloper. Created function will be available in user defined section of XSLT Mapper.
Step1:- Create Java class to write the User defined function. The below Java code will convert long value into decimal value.
package com.geo.xpath;
public class LongToNumericPrimitiveTypesExample {
public static double LongToNumericPrimitiveTypes (Long input){
Long lObj = new Long("input");
double d = lObj.doubleValue();
return d;
}
}
Step 2:- Create ext-mapper-xpath-functions-config.xml file to contain the following value
<soa-xpath-functions version="11.1.1"
xmlns="http://xmlns.oracle.com/soa/config/xpath"
xmlns:geo="http://www.oracle.com/XSL/Transform/java/com.geo.xpath.LongToNumericPrimitiveTypesExample">
<function name="geo:LongToNumericPrimitiveTypes">
<className>com.geo.xpath.LongToNumericPrimitiveTypesExample</className>
<return type="number"/>
<params>
<param name="input" type="number"/>
</params>
<desc/>
<detail>
<![CDATA[This function convert long to decimal message.]]>
</detail>
</function>
</soa-xpath-functions>
In this XML basically Java class method is defined. Put this XML inside the META-INF folder in the same java class and create a JAR file of it.
Step 3:- For creating JAR file from JDeveloper. Right Click on the Java project select New -> Deployment Profile(From option select JAR File) then name the jar file and click next. Accept the all default value and the click Finish. Now right click again on the same project and click on the deploy option and deploy that JAR Archive. It will create the JAR file on to location like JDeveloper\mywork\Application1\LongTodecimalConversion\deploy. Verify if in the created jar file META-INF folder contains the ext-mapper-xpath-functions-config.xml file.
Step 4:- Now in JDeveloper select the Tools -> Preferences -> SOA and use the Add button to select the created jar. Now restart the JDeveloper. Created function will be available in user defined section of XSLT Mapper.
Now this is available at design time. Test it using the test functionality of XSLT Mapper.
Step 5:- Now to make it available at run time put ext-mapper-xpath-functions-config.xml on the location <<SOAOracle_HOME>>\Oracle_SOA1\soa\modules\oracle.soa.ext_11.1.1\classes\META-INF and place the built jar file on the location <<SOAOracle_HOME>>\user_projects\domains\soa_domain\lib. Then restart the server. Now deploy the built project and test this user defined Custom XPATH function.
Hope this will help.
followed all the steps but still not able to find user defined functions in the XSLT mapper
ReplyDeleteHave you followed all the steps which required to do in jdeveloper?
Delete