I have two parts of this question.
Response data received from the SOAP request:
<ns:dataTransferResponsePart xmlns:ns="http://xxxxxxxxxxx.xxxx.xxx" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><responseData><formattedData><textData>Object ID 2019-01-09_R1JKES00000001 2019-04-22_R1JKTS00000040 </textData></formattedData></responseData></ns:dataTransferResponsePart>
The use case is to fetch the text content from the above response data tab of <textData>
Part 1:
One is to parse data from a SOAP based XML response and content from specific tag from the response.
I tried with multiple ways but that was snot successful. I tried creating Exchange property in the content modifier to forward the data by Xpath as follows,
value is given as : /ns:dataTransferResponsePart/responseData/formattedData/textData
I have tried the /ns: namespace to specify in the Namespace Mapping, However this didn't allowed to add as this namespace is used for other source.
part 2:
After giving up on the above approach, I tried with groovy script to parse the xml content and fetch the data from the tag as follows:
import com.sap.gateway.ip.core.customdev.util.Message; import java.util.HashMap; import groovy.util.XmlSlurper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; def Message processData(Message message) { Logger log = LoggerFactory.getLogger(this.getClass()); try { def body = message.getBody(java.lang.String) as String; def downloadResponse = new XmlSlurper().parseText(body); def download_data = downloadResponse.ns:dataTransferResponsePart.responseData.formattedData.textData.text(); message.setData(download_data); } catch (Exception ex) { log.error("processData error",ex); } return message; }
Any help on the parsing and setting the data to message in the body is much appriciated.