Posted By

lucaborace on 08/12/14


Tagged


Versions (?)

Saving SOAPui Response base64 to file


 / Published in: Groovy
 

Salvare la response su file

  1. import org.apache.commons.codec.binary.Base64
  2.  
  3. def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
  4. def holder = groovyUtils.getXmlHolder( "RequestTest#Response" )
  5. // define namespace
  6. // Populate these
  7. holder.namespaces["ns12"] = ""
  8. holder.namespaces["ns23"] =""
  9.  
  10. def textBase64 = holder.getNodeValues( "//ns12:createReportResponse[1]/return[1]/ns23:output[1]" ).toString()
  11.  
  12. def b64 = new Base64()
  13. def zipTextBytes = b64.decode(textBase64.getBytes())
  14.  
  15. def zipFile = new java.io.File("report.pdf")
  16. FileOutputStream fos = new java.io.FileOutputStream(zipFile)
  17. fos.write( zipTextBytes )
  18. fos.flush()
  19. fos.close()
  20. log.info "Temporary PDF file stored as: ${zipFile.getCanonicalPath()}"

Report this snippet  

You need to login to post a comment.