WebService SOAP - BonitaXML Deprecated
Hello everyone,
I am migrating to Bonita 2021.1. In processes I use the WebService SOAP 1.2 connector to retrieve data from Web Services.
The information returned has this format:
https://drive.google.com/file/d/1jJwp3WjIZ-TbjENCWtyBz9cXqcx5I8YM/view?u...
Until now I used this code:
def dades = BonitaXML.evaluateXPathOnVariable(responseDocumentBody,"/get_dadesUltimContracteAmpliatResponse/get_dadesUltimContracteAmpliatResult/text()")
But in the new version BonitaXML signals me as Deprecated and future to disappear. Suggest to use groovy.xml.XmlParser or groovy.xml.XmlSlurper. I would like to make the change, but I just can't find the solution.
Searching the net, I have found this solution:
def request = new XmlSlurper().parseText(responseDocumentBody);
def dades = request.Body.get_dadesUltimContracteAmpliatResponse.get_dadesUltimContracteAmpliatResult;
but when using it it gives me the following error:
No signature of method: groovy.util.XmlSlurper.parseText () is applicable for argument types: (com.sun.org.apache.xerces.internal.dom.DocumentImpl) values: [[#document: null]]
Any ideas ?. Some alternative ?. Thank you very much in advance
Hi,
It looks like you are using the parseText method on a Document
object which only accepts String.
Here is an example snippet on how to handle a Document output:
def request = new XmlSlurper().parseText(XmlUtil.serialize(responseDocumentBody.getDocumentElement()))
// See https://groovy-lang.org/processing-xml.html to see how to navigate in the request
return request.text()
HTH
Romain
Comments
Thank you so much !.