Tuesday 8 August 2023

Find all the messages from the unformatted xml and place in newline




import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

import groovy.xml.XmlUtil;

import groovy.util.*;


def Message processData(Message message) {

def body = message.getBody(java.lang.String) as String;

def xml = new XmlSlurper().parseText(body)

def error = xml.'**'.findAll { it.name() == 'message' }*.text().join('\n')

message.setBody(error);

return message;

}








No comments:

Post a Comment