Numerator
Numerator

Reputation: 1409

How can I decompress a GET response using SOAPUI

I am getting a zipped response from a server.

with Using CURL and | gunzip I am able to get the unzipped content response, but I would like not to use CURL and decompress it directly via SOAPUI, by a header, or by a script.

I tried to write something like:

def responseBody=testRunner.testCase.getTestStepByName("getZIp").httpRequest.response.responseContent;
InputStream ins = new ByteArrayInputStream(responseBody.getBytes())

    log.info responseBody
    def outFile = new FileOutputStream(new File('/users/trythis.zip'))
    if (ins) {
    com.eviware.soapui.support.Tools.writeAll(outFile, ins )
    }
    ins.close()
    outFile.close()

but the data is still compressed.

Upvotes: 2

Views: 531

Answers (2)

Chris Adams
Chris Adams

Reputation: 1454

In SoapUI's preferences, there are options for working with API's which expected compressed payloads and/or send back compressed responses.

I've used this in the past and SoapUI decompresses the response and presents that in the UI so I didn't have to resort to Groovy scripts to read the response.

Upvotes: 1

injecteer
injecteer

Reputation: 20699

something straight-forward like:

InputStream ins = new ByteArrayInputStream(responseBody.getBytes())
def outFile = new File('/users/trythis.txt')
new GZIPInputStream( ins ).withReader{ outFile << it }

Upvotes: 1

Related Questions