How to split xml in different parts based on some element in WSO2 ESB



I am trying to split incoming xml message in two messages and want to send on two different endpoints. like my message is:



<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE">
<soapenv:Body>



<CMMHeader>
<MessageTimeStamp>2014-11-13T16:32:58.</MessageTimeStamp>
<MessageId></MessageId>
<ComponentId>GLBooking</ComponentId>
<From>Silta</From> <To>GLBookingQueue</To>
<CorrelationId></CorrelationId>
<ProcessId></ProcessId>
<EventId></EventId>
<Domain>Finance</Domain>
</CMMHeader>

<tns:GLBooking>
<cdm:SubLedger >Payroll </cdm:SubLedger>
<cdm:Identifier>10004 </cdm:Identifier>
<cdm:CreatedBy>test</cdm:CreatedBy>
<cdm:CompanyCodeTo>3010</cdm:CompanyCodeTo>
<cdm:PostingDate>20141009</cdm:PostingDate>
<cdm:CreationDate>20140901</cdm:CreationDate>
<cdm:GLBookingLine>
<cdm:LineNumber>1</cdm:LineNumber>
<cdm:AccountNumber>0000133200</cdm:AccountNumber>
<cdm:Description> </cdm:Description>
<cdm:TaxCode> </cdm:TaxCode>
<cdm:CostCenter> </cdm:CostCenter>
<cdm:Currency>EUR</cdm:Currency>
<cdm:Amount>00000840213</cdm:Amount>
<cdm:DebetCredit>C</cdm:DebetCredit>
<cdm:BaseAmount>00000000000</cdm:BaseAmount>
</cdm:GLBookingLine>
<cdm:GLBookingLine>
<cdm:LineNumber>2</cdm:LineNumber>
<cdm:AccountNumber>0000133205</cdm:AccountNumber>
<cdm:Description> </cdm:Description>
<cdm:TaxCode> </cdm:TaxCode>
<cdm:CostCenter> </cdm:CostCenter>
<cdm:Currency>EUR</cdm:Currency>
<cdm:Amount>00000213120</cdm:Amount>
<cdm:DebetCredit>C</cdm:DebetCredit>
<cdm:BaseAmount>00000000000</cdm:BaseAmount>
</cdm:GLBookingLine>
</tns:GLBooking>
</GLBookingMessage>
</soapenv:Body>
</soapenv:Envelope>


I want to split this message into two mesage.



<CMMHeader>
<MessageTimeStamp>2014-11-13T16:32:58.</MessageTimeStamp>
<MessageId></MessageId>
<ComponentId>GLBookingFileAdapter</ComponentId>
<From>Silta</From> <To>GLBookingQueue</To>
<CorrelationId></CorrelationId>
<ProcessId></ProcessId>
<EventId></EventId>
<Domain>Finance</Domain>
</CMMHeader>


and



<GLBookingMessage>
<tns:GLBooking>
<cdm:SubLedger >Payroll </cdm:SubLedger>
<cdm:Identifier>10004 </cdm:Identifier>
<cdm:CreatedBy>Silta</cdm:CreatedBy>
<cdm:CompanyCodeTo>3010</cdm:CompanyCodeTo>
<cdm:PostingDate>20141009</cdm:PostingDate>
<cdm:CreationDate>20140901</cdm:CreationDate>
<cdm:GLBookingLine>
<cdm:LineNumber>1</cdm:LineNumber>
<cdm:AccountNumber>0000133200</cdm:AccountNumber>
<cdm:Description> </cdm:Description>
<cdm:TaxCode> </cdm:TaxCode>
<cdm:CostCenter> </cdm:CostCenter>
<cdm:Currency>EUR</cdm:Currency>
<cdm:Amount>00000840213</cdm:Amount>
<cdm:DebetCredit>C</cdm:DebetCredit>
<cdm:BaseAmount>00000000000</cdm:BaseAmount>
</cdm:GLBookingLine>
<cdm:GLBookingLine>
<cdm:LineNumber>2</cdm:LineNumber>
<cdm:AccountNumber>0000133205</cdm:AccountNumber>
<cdm:Description> </cdm:Description>
<cdm:TaxCode> </cdm:TaxCode>
<cdm:CostCenter> </cdm:CostCenter>
<cdm:Currency>EUR</cdm:Currency>
<cdm:Amount>00000213120</cdm:Amount>
<cdm:DebetCredit>C</cdm:DebetCredit>
<cdm:BaseAmount>00000000000</cdm:BaseAmount>
</cdm:GLBookingLine>
</tns:GLBooking>
</GLBookingMessage>


Please help me. it will be a great favour.


No comments:

Post a Comment