Using custom XPath functions
In this recipe, we will show how to implement custom XPath functions, which extends the collection of XPath functions available with the OSB platform. We will use the same functionality that we used in the Using the Java Callout action to invoke Java code recipe, but now make the calculate checksum functionality available as an XPath function.
Getting ready
You can import the OSB project containing the base setup for this recipe into Eclipse OEPE from \chapter-9\getting-ready\using-custom-xpath-function
.
How to do it...
First we have to create the Java functionality we like to expose as a custom XPath function. We will reuse the same Java class we used in the Using the Java Callout action to invoke Java code recipe which is shown here:
package osbcookbook.util.checksum; import java.util.zip.CRC32; import java.util.zip.Checksum; public class ChecksumUtil { public static long calculateChecksum(String data) { Checksum checksum = new CRC32(); checksum.update...