Tuesday 30 July 2024

ODATA xml message unformatted xml and shift to new line

 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