0
votes

I have:

  1. Raw xml filled by a select query.This xml transformed into a HL7 message
  2. One of the tags of this xml represents a clob column from a table in the database
  3. I mapped this data (from edit transformer section) as a variable.
  4. Now I am trying to convert this variable into a base64 string then replace it in my transformed hl7 message. 5.I tried this conversion on a destination channel which is a javascript writer.

I read and tried several conversion methods like

Packages.org.apache.commons.codec.binary.Base64.encodeBase64String();

I have got only error messages like :

EvaluatorException: Can't find method org.apache.commons.codec.binary.Base64.encodeBase64String(java.lang.String);

Code piece:

var ads=$('V_REPORT_CLOB');
var encoded = Packages.org.apache.commons.codec.binary.Base64.encodeBase64String(ads.toString());

It is pretty clear that I am a newbie on that.How can I manage to do this conversion ?

1

1 Answers

0
votes

Here is what I use for Base64 encoding a string with your var substituted.

//Encode Base 64//
var ads = $('V_REPORT_CLOB');
var adsLength = ads.length;
var base64Bytes = [];

for(i = 0; i < adsLength;i++){
    base64Bytes.push(ads.charCodeAt(i));
}

var encodedData = FileUtil.encode(base64Bytes);