Forum Discussion
Holly_Greger
16 years agoContributor
Sorry 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!
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!