Skip to Content


Base64 is an encoding scheme to represent binary data in a textual format. In the area of integration, occasionally there are requirements to handle content that are encoded in Base64. Below are some example usage of Base64:-

  • Store binary data (PDF, image) in text format
  • Embed binary data in an XML
  • Compress data for efficient transfer over text-based transmission medium

Currently, there is no standard feature in PI/PO to handle Base64 content. It is normally handled through custom development of UDFs or Java mappings. Unfortunately, although there is an idea submission at Idea Place by Aaron Myers for a Base64 standard adapter module (in the likes of PayloapZipBean, etc), the status of the submission has not changed in the past two years since the submission

Enter Base64DecodeConverter, the latest addition to the family of FormatConversionBean converters It is a reusable and reconfigurable converter that handles decoding of Base64 content in plain text file or embedded in an XML payload.

Source Code and Deployment Archive

Refer to following blog on location of source code and/or EAR deployment file.

FormatConversionBean – One Bean to rule them all!

Usage of Module in Communication Channel

Module Processing Sequence

Number Module Name Type Module Key

<Depending on position of module in chain>

1) Asynchronous scenario,

Normally before the last module in channels

2) Synchronous scenario,

Before last module to convert request payload

After last module to convert response payload

Custom_AF_Modules/FormatConversionBean Local Enterprise Bean <Any Arbitrary Value>

Module Parameter Reference

Below are the parameters for configuration of the module for Base64 decoding. Certain parameters will automatically inherit the default values if it is not configured.

Parameter Name Allowed values Default value Remarks
converterClass Required field. Determines conversion class
inputType plain, xml

Required field. Indicates type of input data

  • plain = Base64 string provided as plain input text
  • xml = Base64 string embedded in XML element of XML payload

Required field when inputType = ‘xml’.

XPath expression to location of XML element containing Base64 string

zippedContent Y,N N Indicates that content was compressed before encoding into Base64 string
contentType Specifies the MIME content type of the output after decoding

pre, post

Saves a log version of the message that is viewable in Message Monitor

  • pre = saves payload before conversion
  • post = saves payload after conversion
logLocation Name of log version when messageLog is populated. Location defaulted to value in messageLog if logLocation not populated

Example Scenarios

Here are some example scenarios of the behavior of the conversion based on different configuration options.

Scenario 1

  • Base64 string in plain input text
  • Content was compressed before encoding into Base64, therefore decompression is required after decoding

Module parameters

Parameter Name Parameter Value
inputType plain
zippedContent Y


Input /wp-content/uploads/2015/04/in1_695515.png
Output /wp-content/uploads/2015/04/out1_695514.png

Scenario 2

Screenshot of actual configuration and testing are shown below.

  • Base64 string embedded in XML payload
  • XPath expression to location of field containing Base64 content provided
  • Output MIME content type specified

The test data is created by using Base64 Encode – Online to produce the Base64 string as shown below, and embedding it in an XML.


Module configuration on an SFTP receiver channel.


The XML input payload is sent via the Send Test message function.


The log version ‘post’ shows the content after decoding. The decoded content matches the original content as expected.


The audit log shows the trace of steps being executed by the module.



With this new addition to FormatConversionBean, decoding of Base64 content can now be easily handled without additional custom development

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Former Member

    Hi Eng Swee Yeoh ,

    First and foremost thanks for the wonderful blog and introducing this bean to the family.I must tell it has eased lot of our efforts.

    We are trying to use this Custom Adapter Module as per your blog wherein we are trying to decode an field level Base 64 encrypted file.

    Consider there are 4 fields in an XML file wherein the 3rd field is coming encoded. Now in the output I need an XML format wherein I am trying to capture all the 4 fields and the 3rd field should be decoded.

    I am using the below configuration in the Module Parameter of Sender Channel:Module Parameter.jpg

    Now when I am doing an end to end test. The file is getting picked up and but I am getting an error during processing:

    Transmitting the message to endpoint <local> using connection File_ failed, due to: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_Encode_to_Decode_; Details:; Content is not allowed in prolog.

    And strange part is when I check the payload only the XPATH mentioned field is getting generated with the decoded value and the rest of the field is not visible at all.Also I am not getting the output in the XML format. Is it something I am missing in here where in you could help us out?



  2. Former Member

    Hi Eng Swee Yeoh ,

    is it possible to put the encoded string as attachment, e.g. when you get an pdf as base64 encoded string in a xml message and want to add the decoded PDF als attachment to pi message?


    1. Eng Swee Yeoh Post author

      Hi Thorsten

      The functionality as-is do not have that capability. Due to work commitments, I don’t have the time to enhance it currently. The project is available on GitHub for anyone to fork and enhance as required.

      Eng Swee

    1. Eng Swee Yeoh Post author

      Thanks for the feedback Jovane. Always good to know that this is actually being used “out there” and that it works 🙂


      Eng Swee

      1. Former Member

        Eng, I receive the filename into XML payload. I’m trying change filename using “Variable Substitution” but don’t have success using FormatConversionBean. I also trying Dynamic Configuration with Message Mapping and also without success. If I remove FormatConversionBean the Variable Substituition works fine. Do you know how rename the output with filename in payload?


        Jovane Marques


Leave a Reply