Buschfunk
15 years agoFrequent Contributor
How to use property "Encode Attachments" correctly?
Hello,
I have set up a webservice mock which sends responses with dynamic content read from a database. Some of the response nodes shall contain base64-encoded binary data, e.g. images.
For debugging purposes, I use the following statement which works fine. It shows the base64 representation of the image.
If, however, I use the SQL result as a context property for further usage in the response it is not handled correctly, i.e. instead of its base64 representation only a string like [B@156... is used.
The property "Encode attachments" is set to true.
In the Groovy script:
In the response:
I have set up a webservice mock which sends responses with dynamic content read from a database. Some of the response nodes shall contain base64-encoded binary data, e.g. images.
For debugging purposes, I use the following statement which works fine. It shows the base64 representation of the image.
log.info(sqlResult['IMAGE'].encodeBase64())
If, however, I use the SQL result as a context property for further usage in the response it is not handled correctly, i.e. instead of its base64 representation only a string like [B@156... is used.
The property "Encode attachments" is set to true.
In the Groovy script:
context.image = sqlResult['IMAGE']
In the response:
${image}