SpiderHibs
16 years agoNew Contributor
Saving a binary file from SOAP message
Hi,
I am new to soapUI and have been impressed with what it can do. I am however having a problem with extracting some binary data from a SOAP message.
Here is my setup:
soapUI v3.5
CentOS 5.4
I have been given a WSDL by a customer which I have imported as a MockService within soapUI. The WSDL has a CreateRecord service which I send a video to. I want to test that the video I have sent in the Request is the same at when received.
A sample message is below (I have removed the content as it is too large to display here)
I have then written a script to go into the "AfterRequest Script" section of the mock Service (named "CreateRecordServicePortBinding MockService"):
import org.apache.commons.codec.binary.Base64
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
filename = "/tmp/soapUI.mpg"
def objFile = new java.io.File(filename)
def holder = groovyUtils.getXmlHolder("createRecord - Request 1#Request");
holder.declareNamespace('ns2','http://create.ws.test/');
def byteArray = holder.getNodeValue("//ns1:binaryData" )
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)
I have run the script and receive an JAva.lang.NullPointerException on the getXmlHolder call. I realise that this is because it can't find the information it's looking for.
I have been reading up on the parameters but I am having trouble understanding what information should be passed as a parameter to the getXmlHolder() method. Can anyone help?
Thanks.
Can anyone
I am new to soapUI and have been impressed with what it can do. I am however having a problem with extracting some binary data from a SOAP message.
Here is my setup:
soapUI v3.5
CentOS 5.4
I have been given a WSDL by a customer which I have imported as a MockService within soapUI. The WSDL has a CreateRecord service which I send a video to. I want to test that the video I have sent in the Request is the same at when received.
A sample message is below (I have removed the content as it is too large to display here)
I have then written a script to go into the "AfterRequest Script" section of the mock Service (named "CreateRecordServicePortBinding MockService"):
import org.apache.commons.codec.binary.Base64
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
filename = "/tmp/soapUI.mpg"
def objFile = new java.io.File(filename)
def holder = groovyUtils.getXmlHolder("createRecord - Request 1#Request");
holder.declareNamespace('ns2','http://create.ws.test/');
def byteArray = holder.getNodeValue("//ns1:binaryData" )
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)
I have run the script and receive an JAva.lang.NullPointerException on the getXmlHolder call. I realise that this is because it can't find the information it's looking for.
I have been reading up on the parameters but I am having trouble understanding what information should be passed as a parameter to the getXmlHolder() method. Can anyone help?
Thanks.
Can anyone
