I am using SOAP UI 3.0.1 for testing my web service which returns a byte array. I want to save the byte array as a word file. How do I accomplish it using Groovy Script or any other way? The web service response is, 0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAA...............................
+1
A:
Bingo!!
import org.apache.commons.codec.binary.Base64 def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); filename = groovyUtils.projectPath + "\" +System.currentTimeMillis()+ ".doc" def objFile = new java.io.File(filename) def holder = groovyUtils.getXmlHolder('GetDocument#Response'); holder.declareNamespace('ns1','Utlities.Service.Documents'); def byteArray = holder.getNodeValue("//ns1:GetDocumentResponse[1]/ns1:GetDocumentResult" ) def b64 = new Base64() def textBytes = b64.decode(byteArray.getBytes()) FileOutputStream fos = new java.io.FileOutputStream(objFile); fos.write( textBytes ); fos.flush(); fos.close(); log.info("Output file: " + filename)
sam
2010-03-22 13:05:28