I am trying to parse the XML response from soap webservice using as below
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SignResult xmlns="http://www.tw.com/tsswitch">
<Result>
<Code>string</Code>
<Desc>string</Desc>
</Result>
<SignedDocument>base64Binary</SignedDocument>
<Archive>base64Binary</Archive>
<Details>string</Details>
</SignResult>
</soap:Body>
</soap:Envelope>
Below is my groovy code to convert XML response to desired variables
def responseXML = EntityUtils.toString(httpResponse.getEntity());
def signResponse = new XmlSlurper().parseText(responseXML)
def signedDocument = new XmlSlurper().parseText(responseXML).Body.SignResult.SignedDocument
def resultCode = new XmlSlurper().parseText(responseXML).Body.SignResult.Result.Code
def resultDesc = new XmlSlurper().parseText(responseXML).Body.SignResult.Result.Desc
def archive = new XmlSlurper().parseText(responseXML).Body.SignResult.Archive
def details = new XmlSlurper().parseText(responseXML).Body.SignResult.Details
I am trying to convert the signedDocument
to byte[]
as below
def document = signedDocument as byte[]
but am getting this below exception
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object with class 'groovy.util.slurpersupport.NodeChildren' to class 'byte'
Can someone help mw with this?