Forum Discussion

mmoser18's avatar
mmoser18
Frequent Contributor
5 years ago

How to return binary Mock Responses?

I am trying to create a REST mock that returns a binary payload. By binary I mean the content of a file byte by byte "as is", without any character encoding/conversion or anything interfering.

Or in other words: If my browser saves the response to a file I expect this file to be bitwise identical to the file that the mock has read from disk.

 

A very similar question has been posed here:

https://community.smartbear.com/t5/API-Functional-Security-Testing/service-responses-binary-data/m-p/95313#M23252

... but the code shown there does not work (anymore or never did?)

 

I have come as far as that I have an array of byte's in my hand. But now I am stuck. Nothing I found via Google on that subject worked. The only way I found that returned something was to convert the bytes to a String and assign that to mockResponse.content and place "${content}" into the mock's response editor. But doing so the content is converted first to Java's internal String encoding and later to a UTF-8 and gets completely scrambled along the way.

 

Is a binary response at all possible with SOAP-UI? If so: how?