Many times we have requirements to decode the “base64 encoded message” in XI/PI so it can be used in IE for message processing. In this blog I tried to demostrate about the steps that will help us to decode the data using Java Mapping

Actual source XML


After Base64 Encoding: (incoming message to XI/PI)



!|height=94|alt=Payload after Base64 Encoding|width=593|src=|border=0



+Help: For prototype purpose use the URL  ( to encode your actual payload. +



There are two ways to handle such scenarios 


  • Java Mapping : Easy to design, develop and able to test using Java IDE externally. Also possible to test it in Interface Mapping without executing/testing the whole interface.

So each of the above has there own advantages and disadvantages. Here with the help of Java mapping we will look how it is possible to implement such scenario. In the next blog I will demostrate the same using Custom Adapter Module.

*Step 1: Convert the input.txt information into and XML format (XML template) using File Content Conversion in the Sender File Adapter.

node contains the actual encoded Information/XML payload.

!|height=99|alt=Template XML generated by using FCC.|width=647|src=|border=0!

Step 2: Java code for Base64 decoding, this is simply lines of Java language just to demostrate about Base64 decoding in XI. You can uses other API’s in order to achieve Base64 decoding/Encoding.


package domDemo;

import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

import sun.misc.BASE64Decoder;

public class JMDecodeDetails implements StreamTransformation {
 private Map param=null;
 public void setParameter(Map param){
 public void execute(InputStream in, OutputStream out){
   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   DocumentBuilder builder = factory.newDocumentBuilder();
   Document docOld = builder.parse(in);
   //Get the node name Details that contains the Based64 Encoded information..
   NodeList details = docOld.getElementsByTagName(“Details”);
   //Get the Text of Node.
   String data = details.item(0).getChildNodes().item(0).getNodeValue();
   //Instantiate an object of BASE64Decoder…
   BASE64Decoder decoder =  new BASE64Decoder();
   //Decode the encoded information….
   byte b[] = decoder.decodeBuffer(data);
   //Parse the decoded data i.e. nothing but the real payload….
   Document docNew = builder.parse(new ByteArrayInputStream(b));
   TransformerFactory transformerFactory = TransformerFactory.newInstance();
   Transformer transformer =  transformerFactory.newTransformer();
   DOMSource source = new DOMSource(docNew);
   StreamResult result = new StreamResult(out);
  catch (Exception e){

Step 3: Create the jar file, import it into IR and assign it in Interface Mapping

!|height=197|alt=Assign Java Class in Interface Mapping|width=692|src=|border=0!


Step 4: *Test you Interface Mapping

!|height=122|alt=Test your Interface mapping|width=700|src=|border=0!

New NetWeaver Information at

Very Helpfull

User Rating: Be the first one !