cancel
Showing results for 
Search instead for 
Did you mean: 

Convert one filed to base64binary (byte)

former_member190239
Participant
0 Kudos

I have a file to webservice scenario in which all fileds that are input to the webservice are string so I map them from the source side after applyign graphical functions.. but one field in target side has a data type base64Binary

Is this same as byte? or this is base64ecoding?

Also can you please let me know I can accomplish the mapping usign UDF?

when I do a return inputstring.getBytes() , its throwing an error

Regards,

Tej

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

HI  Ravi,


Is this same as byte? or this is base64ecoding?

This represents an encoding of a binary file, but the representation is in base64. With base64 you can get text or binary data but the algorithm is the same. It is base64encoding


Also can you please let me know I can accomplish the mapping usign UDF?

I think that you want to take the file a converting it in base64 and to set a XML tag with this value.

You can use a java mapping to do this. You use the file adapter to take the file and later in the java mapping you do the base64 conversion:

1. To read a file and to deal with it in java mapping: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56...

2. Conversion to base64 of an inputstream: How do you convert an InputStream to a base64 string in Scala? - Stack Overflow

3. Finally, you take this result and string and you converts the target XML manually.

Regards.

former_member190239
Participant
0 Kudos

Thanks Inaki....

My requirement is follows...file to webservice

one field in the target side called DATA (WS) , is to be mapped to one field in from the source side CONTENT (FILE)....

but the data type in the target field is of type "base64Binary" (WS), whereas the data type of the field CONTENT(FILE) is string..

the rest of the fields in the target side are mapped one to one with the fields from the source side.. its all string.. except for the field DATA

sunilchandra007
Active Contributor
0 Kudos

A simple UDF can help. Please check

Regards,

Sunil Chandra

Answers (3)

Answers (3)

former_member190239
Participant
0 Kudos

Hello Experts,

need help with Strign to byte in udf .. pls let em know

former_member220103
Active Participant
0 Kudos

hi,

You can convert String to Byte Array as below:

byte[] btaInput = strInput.getBytes();

Thanks,

Kanda

former_member190239
Participant
0 Kudos

Hi EXperts,

Any help on this?

Converting one field of input from string to byte stream?

former_member220103
Active Participant
0 Kudos

Hi,

You can convert the base64Binary into string as below:

byte[] encodedString =  Base64.encodeBase64(strInput.getBytes());

return (encodedString.toString());

Thanks,

Kanda

former_member190239
Participant
0 Kudos

Im actually tryign the opposite...

convertign strign to base64boolean i.e