Friday, 9 October 2015

Decoding Base64 Encoded data using Java Embedding Activity

Recently faced critical issue while decoding Base64 encoded data.After doing lot of R&D finally achieved it by using Native Java Code.

Here are the step to step  process to achieve the same.
  1. Created String variable with the name "MyRowIDVar".
  2. Copied  Base64 encoded data into MyRowIDVar variable using Assign activity.
  3. Drag & Drop Java Embedding activity in middle of Bpel process and added below java code snippet in it.                                                              String rowid = (String)getVariableData("MyRowIdVar");       
    Base64Decoder Decoder = new Base64Decoder();   
    try                                          
     {             
        String decodedAmpersand = Base64Decoder.decode(rowid);  
        setVariableData("AA",Base64Decoder.decode(rowid));        
     }                                          
    catch(Exception e)                                          
     {                                          
        e.printStackTrace();                                           
     }
  4. we need to import required classes into bpel code  as shown below.
     <bpelx:exec import="oracle.soa.common.util.*" />
     <bpelx:exec import="java.lang.*" />
  5. When you open Bpel source code it should be looking like this.                            <bpelx:exec     import="oracle.soa.common.util.*"/>
    <bpelx:exec import="java.lang.*"/>
    <bpelx:exec name="DecodeBase64" version="1.5" language="java">
          <![CDATA[String rowid = (String)getVariableData("MyRowIdVar");       
       Base64Decoder Decoder = new Base64Decoder();   
       try                                          
       {             
          String decodedAmpersand = Base64Decoder.decode(rowid);  
          setVariableData("
    MyRowIdVar",Base64Decoder.decode(rowid));        
       }                                          
      catch(Exception e)                                          
      {                                          
        e.printStackTrace();                                           
      }]]>
    </bpelx:exec>
  6.  Finally in MyRowIdVar variable having Decoded Base64 data which can be processed further as per the requirement.
  7. Below are few screen shots for the reference.   
Keep Smile, Happy Coding..:)

No comments:

Post a Comment