0

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 Answers1

0

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);
Boosh
  • 1
  • 1
  • Hmm it seems it doesnt raise an error bu I am getting null from encodedData when log it into server log and also at my updated column on the db :/ – SophisticatedUndoing Jul 11 '18 at 06:30
  • Is your variable 'ads' a clob or a string when you're trying to encode it? When I have pulled clob data from a database it has first had to be converted to a string before any manipulation could be done. string = clob.getSubString(1,clob.length()); – Boosh Jul 11 '18 at 12:54