How to convert string representation of file to binary from web service

2
Hello, I am using a web service that returns a file as a string. When I try to copy this to my entity in the XML-Domain mapping I get an error 'unable to convert string to binary...' I get this, however I wonder how I can handle this situation. I'm guessing I will need to use some custom Java code. Any thoughts? Thanks!!
asked
1 answers
2

Is this string a 64baseEncodedString? If that's so you can map this string into the Content attribute of your File entity in your xml-to-domain mapping. The mapping will convert this file automatically.

Edit after comment:

Andrew, my mistake. You can map only a binary to the Contents attribute. So that wouldn't work for you. But you can do it slightly different. Save the returned string in a string attribute. Then you can use a java-action to decode the Base64encoded string into a system.image generalised object.

Basically you need to add a string attribute to your image entity. This entity have to be a generalisation of the system.image entity. After you're mapping you have the convert the string into a binary with the Base64 decode java-action.

You could look at http://www.stackoverflow.com for a java-action to decode to string. Or maybe some nice guy on this forum can help you out with a java-action.

answered