Forum Discussion
4 Replies
- Hi,
not sure what you mean by "stream" here, can you show a screenshot of the raw response in soapUI?
regards!
/Ole
eviware.com - Holly_GregerContributorWe are simply getting back a Filestream from a webservice thus the output is unreadable. ie:
ie:"<soap response>P3DJS233JMFMVHGNGNDFLKJGK234JNGMLKSOJI09BFDSNMG...</soap response>"
There are several ways to convert a Filestrem into a readable format (ie: XML) available however I do not see a way to do this with Groovy Scriptiing / Javascript which are both supported by SoapUI UNLESS there is another way to use SoapUI's scripting functionality to use another programming language (ie: C#) - Is the response encrypted in some way?
Or possibly, you sould send us the C# or Java code you would use to convert it, and we will see how it can be converted to groovy.
/Nenad
http://eviware.com - Holly_GregerContributorSorry I've taken so long to respond. I actually figured it out. The stream is a c# FileStream which pretty much streams a Byte array, now i used a Base64 decoder to reconstruct it on the other end.
import org.apache.commons.codec.binary.Base64
// Step 1: Access element Base64-encoded text content and Base64 decode it
String tempXMLFilename = "temp.XML"
def textBase64 = context.expand('${RetrieveReport - Request 1#Response#//ns1:StreamReportResponse[1]/ns1:ReportStream[1]}' )
def b64 = new Base64()
def XMLTextBytes = b64.decode(textBase64.getBytes())
// Step 2: Output XML raw text into a temporary file
def XMLFile = new java.io.File("Data\\" + tempXMLFilename)
FileOutputStream fos = new java.io.FileOutputStream(XMLFile)
fos.write( XMLTextBytes )
fos.flush()
fos.close()
log.info "Temporary XML file stored as: ${XMLFile.getCanonicalPath()}"
def report = new XmlParser().parse(XMLFile.getCanonicalPath())
This does it!