Tuesday, 21 November 2017

Direct method to decode Base64 in OSB

I had a requirement to do decode a Base64 string in OSB. I did a search and every blogs explained to do it using Java class, but i don't wanted to use Java callout.

In hunt of a easier approach i was able to figure out that using XSLT java call to do the base64 decode. Then you don't have to do the proxy java callout, and also you can save yourself from trouble of uploading some custom jar file .

Lets see how to do it-

Base 64 decode can be done using the xslt function "decode".
The class "weblogic.apache.xerces.impl.dv.util.Base64" is available inside "com.bea.core.apache_1.3.0.1.jar"

Following namespace had to be used to make a successful call  -

"http://www.oracle.com/XSL/Transform/java/weblogic.apache.xerces.impl.dv.util.Base64"

The above is under the weblogic package and was working till 12.2.1.2 but the same stopped working in 12.2.1.3 version.

For 12.2.1.3 found below which works perfectly fine. Also found that below namespace can be used in 12.1.3 and any of the above versions.

http://www.oracle.com/XSL/Transform/java/oracle.soa.common.util.Base64Decoder



Sample Code FYR-
====================
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc64="http://www.oracle.com/XSL/Transform/java/oracle.soa.common.util.Base64Decoder"
exclude-result-prefixes=" dc64 ">
 <xsl:template match="/">
 <Out>
       <xsl:value-of select="dc64:decode('Your base64 string\variable\XPATH here')"/>
   </fOut>
 </xsl:template>
</xsl:stylesheet>




Happy coding, Happy learning :) 

7 comments:

  1. Hi Can we add the same for encoding string to base64

    ReplyDelete
    Replies
    1. Hi Dev

      only decode method is available in the class, so encode will not work.

      Delete
  2. hi The above approach is not working does it need any external jar to be added and if yes which jar and where we need to add.

    ReplyDelete
  3. Hi Arjun,

    xmlns:e64="http://www.oracle.com/XSL/Transform/java/oracle.soa.common.util.Base64Encoder"

    we can you above to encode , i have just tested it now ...

    thanks for starting the blog around this ...

    Regards,
    Rama

    ReplyDelete
  4. Thanks, for the solution.
    During migration to 12c we have encountered the issue
    In 11g it was -xmlns:b64="http://www.oracle.com/XSL/Transform/java/weblogic.apache.xerces.impl.dv.util.Base64"
    replaced with xmlns:d64="http://www.oracle.com/XSL/Transform/java/oracle.soa.common.util.Base64Decoder"

    ReplyDelete
  5. Unfortunately, oracle did move the class in osb “12.2.1.4.0”. The below class namespace should work fine to decode base64 strings

    xmlns:base64=”http://www.oracle.com/XSL/Transform/java/com.bea.nonxml.util.Base64″

    ReplyDelete

"Invalid Composite File" error in Jdeveloper 12C

ISSUE:  While migrating some SOA 11g codes to 12C the migration wizard displays that the codes are successfully migrated. But when the compo...