Skip to Content
author's profile photo Former Member
Former Member

Base64 Encoding using UDF

Hi,

I have a File to SOAP scenario. I am getting a csv file and would like to send that file as base encoded 64.

I am thinking of concatenating all fields of source file in the message mapping and convert it as base64 and map it to soap envelope.

Can anyone let me know any UDF which can be used for this. What are the java classes that needs to be uploaded for this?

Please do let me know the same.

Regards

Anandh.B

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2013 at 08:08 PM

    I know this thread is old but it comes up as result number 1 when searching for "base64 udf"

    My system could not import the class mentioned by Baskar so I'm posting what worked for me:

    Create UDF named b64encode with one input called myInput

    include sun.misc.BASE64Encoder

    public String b64encode(String myInput, Container container) throws StreamTransformationException{

    BASE64Encoder encoder = new BASE64Encoder();

    String encoded = encoder.encode(myInput.getBytes());

    return encoded;

    }

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Aaron,

      I've tried to use the udf you've posted but i get an error while validating:

      • Function b64encode, Line 1: cannot find symbol
        symbol : class BASE64Encoder
        location: class keter.erp.GlobalFunctions.GlobalFunctions
        BASE64Encoder encoder = new BASE64Encoder();

      I've imported the sun.misc.BASE64Decoder.jar.

      can u help ?

  • Posted on Jan 21, 2015 at 07:48 AM

    Hello,

    Oracle recommend against the use of 'sun' packages, although I wouldn't expect you to experience any problems.

    http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html

    An alternative would be to use the Apache Commons Codec jar.

    regards

    Steve

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2012 at 05:06 PM

    >Can anyone let me know any UDF which can be used for this. What are the java classes that needs to be uploaded for this?

    You need to write import statement for this class

    com.sap.aii.utilxi.base64.api.Base64

    and this class contains two static methods namely encode and decode. Refer more about knowing this in the thread

    http://scn.sap.com/thread/1079238

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2012 at 07:27 PM

    Hi,

    Java mapping code in this wiki will help u:

    http://wiki.sdn.sap.com/wiki/display/XI/How+to+Send+Binary+Data+to+RFC+from+XI(or)PI

    Thanks

    Amit Srivastava

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2015 at 01:26 PM

    sun.misc.BASE64Encoder

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 20, 2015 at 01:42 PM

    Hi,

    Can i use the same class for Decoding a base64 field ? does anyone have a UDF ready ?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Well, maybe answered my question but here is a solution which works for me:

      BASE64Decoder decoder = new BASE64Decoder();

      try {

      byte[] decoded = decoder.decodeBuffer(myInput);

      String myOutput = new String(decoded, "UTF-8");

      return myOutput;

      }

      catch (IOException e) {

      return e.toString();

      }

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.