Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
34 views

Groovy Script

The document contains code that processes an incoming message payload by replacing certain XML tags. It logs the incoming and outgoing payloads, and modifies some message properties before returning the message. The code takes the message body as a string, replaces tags like <Lead> with nothing, and sets the modified body back on the message. It also logs the payloads and adds a new property before returning the processed message.

Uploaded by

Mridul Manchanda
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Groovy Script

The document contains code that processes an incoming message payload by replacing certain XML tags. It logs the incoming and outgoing payloads, and modifies some message properties before returning the message. The code takes the message body as a string, replaces tags like <Lead> with nothing, and sets the modified body back on the message. It also logs the payloads and adds a new property before returning the processed message.

Uploaded by

Mridul Manchanda
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

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 messageLog = messageLogFactory.getMessageLog(message);
if(messageLog != null){
messageLog.setStringProperty("Logging#1", "Incoming Payload")
messageLog.addAttachmentAsString("ResponsePayload1:", body, "text/plain");
}

body = body.replaceAll("<Lead>","");
body = body.replaceAll("</Lead>","");

// body = body.substring("10000000","10000001");
//body = body.replaceAll("<Lead>","<LeadCollection><Lead>");
//body = body.replaceAll("</Lead>","</Lead></LeadCollection>");

body = body.replaceAll("MT_Portal_Integration","ns0:MT_Portal_Integration");
//body = body.replaceAll("</Records></MT_Portal_Integration>","");
/*
body = body.replaceAll("<Organization>","<Company>");
body = body.replaceAll("</Organization>","</Company>");
body = body.replaceAll("<Organization/>","<Company/>");

body = body.replaceAll("<Email>","<AccountEMail>");
body = body.replaceAll("</Email>","</AccountEMail>");
body = body.replaceAll("<Email/>","<AccountEMail/>");

body = body.replaceAll("<Website>","<AccountWebsite>");
body = body.replaceAll("</Website>","</AccountWebsite>");
body = body.replaceAll("<Website/>","<AccountWebsite/>");

body = body.replaceAll("<Country>","<AccountCountry>");
body = body.replaceAll("</Country>","</AccountCountry>");
body = body.replaceAll("<Country/>","<AccountCountry/>");

body = body.replaceAll("<State>","<AccountState>");
body = body.replaceAll("</State>","</AccountState>");
body = body.replaceAll("<State/>","<AccountState/>");

body = body.replaceAll("<City>","<AccountCity>");
body = body.replaceAll("</City>","</AccountCity>");
body = body.replaceAll("<City/>","<AccountCity/>");
*/
message.setBody(body);

if(messageLog != null){
messageLog.setStringProperty("Logging#2", "Outgoing Payload")
messageLog.addAttachmentAsString("ResponsePayload2:", body, "text/plain");
}

map = message.getProperties();
value = map.get("oldProperty");
message.setProperty("oldProperty", value + "modified");
message.setProperty("newProperty", "newProperty");

return message;
}

You might also like