Sometimes the functions available in BPEL/XSL will not be sufficient enough to handle our requirements. I came across one such scenario to find out the offset value based on date. So i created a function in java and used it as a custom xpath function in XSL.
You can use the below steps to create a function and bring it to SOA server,
1. Create a Java code.
While creating java code we need to take care of few things,

2. After that, we need to add this method to our custom Xpath function list. Go to below location
Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/classes/META-INF/
Now you have two options.
1a. Once the Java code is ready, generate the class files and copy(as the same folder structure) it to below location in the server,
Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/classes/
or
2a. Once the Java code is done, Create a jar file out of it and copy it to below location in your server,
Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/classes/
2b. Now Run the Build.xml using ant script(How to Run ant script) in below location /omr/soa/Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/

2c. Restart the SOA server
Now you can use the function in any XSL or BPEL by defining the namespace(which we used it in ***-config.xml) in it.
Reference:
http://docs.oracle.com/cd/E23943_01/doc.1111/e17364/customxpath.htm#FPDEV2188
You can use the below steps to create a function and bring it to SOA server,
1. Create a Java code.
While creating java code we need to take care of few things,
- A public static method with the same name as the function name. This method is used by the XSL function for invocation. In this example getTimeZone(String dt)
- A public Class - which will be used in custom xpath xml in next step
- A public static inner class which implements:
- oracle.fabric.common.xml.xpath.IXPathFunction
- In this example, GetTimeZoneFunction - it can be anything relevant
- We have to import oracle.soa.fabric jar into our library, mostly it will be in below installed location. jdeveloper\soa\modules\oracle.soa.fabric_11.1.1\oracle.soa.fabric.jar
2. After that, we need to add this method to our custom Xpath function list. Go to below location
Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/classes/META-INF/
And edit the ext-soa-xpath-functions-config.xml
Please add the content at the bottom,
<function name="tim:getTimeZone">
<className>sample.CustomXpathFunction</className>
<return
type="string"/>
<params>
<param
name="date" type="string"/>
</params>
</function>
also add the namespace on 1st line of the file,
<!--usually the namespace will be the combination of xmlns:tim="http://www.oracle.com/XSL/Transform/java/Package.ClassName-->
Example:
<!--usually the namespace will be the combination of xmlns:tim="http://www.oracle.com/XSL/Transform/java/Package.ClassName-->
Example:
<soa-xpath-functions
xmlns="http://xmlns.oracle.com/soa/config/xpath" xmlns:aia="http://www.oracle.com/XSL/Transform/java/oracle.apps.aia.core.xpath.AIAFunctions"
xmlns:tim="http://www.oracle.com/XSL/Transform/java/sample.CustomXpathFunction">
Now you have two options.
1a. Once the Java code is ready, generate the class files and copy(as the same folder structure) it to below location in the server,
Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/classes/
or
2a. Once the Java code is done, Create a jar file out of it and copy it to below location in your server,
Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/classes/
2b. Now Run the Build.xml using ant script(How to Run ant script) in below location /omr/soa/Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1/

2c. Restart the SOA server
Now you can use the function in any XSL or BPEL by defining the namespace(which we used it in ***-config.xml) in it.
Reference:
http://docs.oracle.com/cd/E23943_01/doc.1111/e17364/customxpath.htm#FPDEV2188
No comments:
Post a Comment