Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: XML outputs base64Binary, how do I handle this?

  1. #1

    Default XML outputs base64Binary, how do I handle this?

    Hope someone can help me...

    I am making a call to a webservice (HTTPPost) and one of my calls returns base64Binary data in the targeted node.

    I've tried parsing this through Get Xml Data and setting the return column as binary, then passing this binary column through a JavaScript which outputs the binary data to a file through a BufferedOutputStream as per the bellow:

    try{
    var f = new File(filename);

    if (!f.exists()){
    f.createNewFile();
    }

    var fos = new FileOutputStream(f);
    var bos = new BufferedOutputStream(fos);
    bos.write(outBytes);
    bos.flush();
    bos.close();
    success = 'Y';
    message = 'OK';
    } catch (e){
    success = 'N';
    message = e.javaException.toString();
    }

    But, it doesn't work... it seems to simply write out the binary as if it where text.

    Any ideas?

  2. #2
    Join Date
    Dec 2009
    Posts
    609

    Default

    Hi,

    where does "outBytes" come from?
    The BufferedOutputStream Thing seems fine so far...

    Cheers,

    Tom

  3. #3

    Default

    Quote Originally Posted by TomS View Post
    Hi,

    where does "outBytes" come from?
    The BufferedOutputStream Thing seems fine so far...

    Cheers,

    Tom
    It comes from the Get XML data... basically is the node I get back which has the data... it is defined as Binary

  4. #4
    Join Date
    Dec 2009
    Posts
    609

    Default

    Hi again,

    well, but XML never is binary itself... maybe base64 encoded, but nothing more... check the calculator step or the modified java script step to decode this string...
    Here is a part of the Wiki:

    Base64 encoding and decoding of strings


    Even though the Apache Commons Base64 encoding and decoding library was available before, the Base64 sample in version 2 used an be.ibridge class to do the work.
    In version 3 we suggest you use the excellent Apache Commons library as shown in the updated sample:

    var bytes = Packages.org.apache.commons.codec.binary.Base64.decodeBase64( F1.getString().getBytes() ); var decString = new Packages.java.lang.String( bytes ); var encString = new Packages.java.lang.String( Packages.org.apache.commons.codec.binary.Base64.encodeBase64( decString.getBytes() ) );

    To be found here:
    http://wiki.pentaho.com/display/EAI/...2.5.x+to+3.0.0

    HTH,

    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.