Skip to Content
0
Aug 21, 2023 at 03:13 PM

Unable to read xml payload

183 Views

Error Details

org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.sun.org.apache.xerces.internal.dom.DocumentImpl to the required type: javax.xml.transform.sax.SAXSource with value [#document: null], cause: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.sun.org.apache.xerces.internal.dom.DocumentImpl to the required type: javax.xml.transform.sax.SAXSource with value [#document: null]
XML payload:

xmlpayload.png

I need to read the "Value" node under <item_option_new> and also the <value> node outside it. If the value matches , I need to set the value in a variable which I can use in my step.

Since I am new to CPI, there could be something obvious and I have already searched most of blogs and posts. Here is my groovy script:

import com.sap.gateway.ip.core.customdev.util.Message; import java.util.HashMap; //import groovy.xml.XmlUtil; import groovy.util.XmlSlurper; def Message processData(Message message) { //Body def body = message.getBody(java.lang.String) ; def properties = message.getProperties(); def xmldoc = new XmlParser().parseText(body); def demo_val = xmldoc.result.item_option_new.value[1].text();

if (demo_val == 'zzzzzz') {

message.setProperty("Username", demo_val);

}

return message; }

BR,

Geet



Attachments

xmlpayload.png (119.5 kB)