Last active
June 4, 2021 09:09
-
-
Save lucaborace/da2cc728732aa6fad18a084f9478da9f to your computer and use it in GitHub Desktop.
Saving SOAPui Response base64 to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.codec.binary.Base64 | |
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) | |
def holder = groovyUtils.getXmlHolder( "RequestTest#Response" ) | |
// define namespace | |
// XXX: Populate these before using this snippet | |
holder.namespaces["ns12"] = "" | |
holder.namespaces["ns23"] ="" | |
def textBase64 = holder.getNodeValues( "//ns12:createReportResponse[1]/return[1]/ns23:output[1]" ).toString() | |
def b64 = new Base64() | |
def zipTextBytes = b64.decode(textBase64.getBytes()) | |
def zipFile = new java.io.File("report.pdf") | |
FileOutputStream fos = new java.io.FileOutputStream(zipFile) | |
fos.write( zipTextBytes ) | |
fos.flush() | |
fos.close() | |
log.info "Temporary PDF file stored as: ${zipFile.getCanonicalPath()}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment