cyw
8 years agoNew Contributor
In ServiceV, how do I return a scripted response without it being overwritten in the Editor?
Hello,
In one of my Virts, I have a Response typed out in XML in the Editor.
I am using the "Script" tab to make Gzip and Base64 the message, as this is what our service expects.
The script looks like this:
def targetStream = new ByteArrayOutputStream()
def zipStream = new GZIPOutputStream(targetStream)
def data = mockResponse.getResponseContent().toString()
zipStream.write(data.getBytes())
zipStream.close()
def zipped = targetStream.toByteArray()
targetStream.close()
mockResponse.setResponseContent(zipped.encodeBase64())
This code "works" because it sends back the message as I expect.
However, it has the side effect of changing the content of the Editor from XML to the encoded/GZipped message.
Is there a way to do this so that it does not overwrite what is in the Editor. i.e. It would be beneficial to be able to see the message in plaintext.
Thanks in advance.