Advertisement
mchive

Untitled

Sep 20th, 2022
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.22 KB | None | 0 0
  1. import com.sap.gateway.ip.core.customdev.util.Message;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import java.io.*;
  6.  
  7. import groovy.xml.*;
  8.  
  9.  
  10. def Message processData(Message message) {
  11.  
  12.     //Body
  13.  
  14.     def body = message.getBody(java.lang.String) as String;
  15.  
  16.    
  17.  
  18.     XmlUtil xmlUtil = new XmlUtil();
  19.  
  20.     def xml = new XmlParser().parseText(body)
  21.  
  22.  
  23.  
  24.     body = body.replaceAll("<multimap:Messages xmlns:multimap=\"http://sap.com/xi/XI/SplitAndMerge\">", "");
  25.  
  26.     body = body.replaceAll("<multimap:Messages>", "");
  27.  
  28.     body = body.replaceAll("</multimap:Messages>", "");
  29.  
  30.    
  31.  
  32.     body = body.replaceAll("<multimap:Message1>","");
  33.  
  34.     body = body.replaceAll("</multimap:Message1>", "");
  35.  
  36.  
  37.  
  38.     body = body.replaceAll("<ns1:queryResponse xmlns:ns1=\"http://sap.com/xi/PASEIN\">", "<positionUpsertResponse>");
  39.  
  40.     body = body.replaceAll("</ns1:queryResponse>", "</positionUpsertResponse>");
  41.  
  42.    
  43.  
  44.     def serialized = XmlUtil.serialize(body)
  45.  
  46.         serialized = serialized.replaceAll('<\\?xml version="1.0" encoding="UTF-8"\\?>', '<\\?xml version="1.0" encoding="UTF-8"\\?> \n')
  47.  
  48.         body = serialized;
  49.  
  50.  
  51.  
  52.     message.setBody(body);
  53.  
  54.     return message;
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement