Groovy script to find the xml field from the input payload and display the value in payload logging title in the monitoring.
Eg:
<root>
<id>112</id>
<request_id>234</request_id>
<task_id>456</task_id>
</root>
Script:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;
def data = new XmlSlurper().parseText(body);
def requestid = data.'**'.findAll { node -> node.name() == 'request_id' }*.text();
def taskid = data.'**'.findAll { node -> node.name() == 'task_id' }*.text();
requestid= requestid.toString().replaceAll("\\[", "");
requestid= requestid.toString().replaceAll('\\]', "");
message.setProperty("requestid",requestid);
taskid= taskid.toString().replaceAll("\\[", "");
taskid= taskid.toString().replaceAll('\\]', "");
message.setProperty("taskid",taskid);
return message;
}
How to get and store value ofrow 2 as property?
ReplyDelete.
..
...value
..
..
...value
..
.