Update 4 Sep 2018: Now available in CPI as well.
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.
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|
PI – com.equalize.xpi.af.modules.base64.Base64DecodeConverter
CPI – com.equalize.converter.core.Base64DecodeConverter
|Required field. Determines conversion class|
|inputType||plain, xml||Required field. Indicates type of input data
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. Available only in PI|
|messageLog||pre, post||Saves a log version of the message that is viewable in Message Monitor
Available only in PI
|logLocation||Name of log version when messageLog is populated. Location defaulted to value in messageLog if logLocation not populated. Available only in PI|
Here are some example scenarios of the behavior of the conversion based on different configuration options.
- Base64 string in plain input text
- Content was compressed before encoding into Base64, therefore decompression is required after decoding
|Parameter Name||Parameter Value|
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