Forum Discussion

jurven007's avatar
jurven007
Occasional Contributor
8 years ago

Unable to unzip file after it's created via a groovy script

Hi all,

 

In a testsuite I used a SOAP VirtResponse to pick up a message that's sent by a certain application. In this SOAP message a download link to a zipfile is present. When I copy/paste this link in Internet Explorer the file can be downloaded.

Via the transfer teststep I copy the download link to a property and in the following teststep I use this property in a http request (method=get). When I execute it I get the following response:

 

<data contentType="application/octet-stream" contentLength="1703">UEsDBBQAAAAIAGtyHEvXN+a18QUAABAiAAAqAAAARzAwMDUuNzg1M2MyMDZlZWJmNDMwNDhkZWVjMmZlZmVhM2FmZGQueG1s7Vptb9s2EP4+YP/B0D7berckI3ExI2sWIG2C2M32lZJOCmuJFEgpSfvrd5IlW5Jlt0nbvWAGggTm3T187nh8SCY5e/OcJqNHEJJydq7oE00ZAQt4SFl8rnxYvR27ypv5zz8/0TQGruv6LM395f3igmr6CEOZnFWWc+Uhz7OZqj49PU3ws8wJCwkRIbAJS9TKRzUmuirzIhpvPuoTU6kxUvksk3OlEGwmgwdIiRynNBBc8igfBzw/oTlvnJ8l7Uz3ZE64iFVD03T1z3fXywpgTFnJIYBtVELZeihO9zxPraw/K5Ib+1xsPwXEVOYgjiaGPzFGrSpYw/g/6RIe00KWQSE/6ZpnGeCksRr7SF3XVH0XmCY/SJ4BQwYTBrmKtsZtcdnxghjSEn2Zf3irSghyZOPHqmbugEvT4Zjym2Zq+q7O4ZfrrLS7APvjFT+gYH8/RrsOQ0shYqT2CExWNrSW5GY+CBo85NieMC878EzdG267fwYWgqiHmkFMPzAqSU5hfqlpml2DtMe7ESTLEhpUhvdQCM5GyxwSCcnormoMUZpqlJZvDyRMKWuc57c/e2e05q7uk6+ps/yRsPhoSktMSX9JSou7X+9vXsYe9/94cbn6cg59whswAREIYOjNijRFo2tHTgSGHxm6Y4U/QYyABJ7jeJYfTTXDrNH24tqgOf0Yypxmi00vzHFLOZpruLqlewZ+TWs/vl8bIypYUOaAEncPIsdKP2QFYn+VG8eqb9UjP9uSzSIvA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fla6vValGjk4q9V9SKd3xiO66Qai5xCJh6BPUJ90gYOADz3PISaVOKvXjVOrABe2kUieV6qiUTTQtcGw/woaxICR+EE7Bch3PNvVIJ95JpU4q9aNUqv/kPKnUSaWGVUoLNNs2IyOyrMAKXSCGMwXb03VPh8B2o5NKP1Tqx6lU91dgf7NKtf/gt/2XjvlfUEsBAhQAFAAAAAgAa3IcS9c35rXxBQAAECIAACoAAAAAAAAAAAAAAAAAAAAAAEcwMDA1Ljc4NTNjMjA2ZWViZjQzMDQ4ZGVlYzJmZWZlYTNhZmRkLnhtbFBLBQYAAAAAAQABAFgAAAA5BgAAAAA=</data>

Next I want to save this file. After I search the forum I followed the steps from https://community.smartbear.com/t5/SoapUI-Pro/how-to-get-the-zip-file-after-running-HTTP-request/td-p/123831.

 

def responseBody=testRunner.testCase.getTestStepByName("04 - Bestand ophalen").httpRequest.response.responseContent;
//InputStream ins = new ByteArrayInputStream(responseBody.getBytes("UTF-8"))
InputStream ins = new ByteArrayInputStream(responseBody.getBytes())
log.info responseBody
def outFile = new FileOutputStream(new File('C:/temp'+'/TestDownload.zip'))
if (ins) {
com.eviware.soapui.support.Tools.writeAll(outFile, ins )
}
ins.close()
outFile.close()

When I execute the above script in a groovy teststep a zipfile is saved but when I try to unzip it I get the following error:

 

 

What am I doing wrong here?

 

N.B.: My ultimate goal would be to open the xml in the zip and execute a schema validation on it. So maybe there is a simpeler flow....?