I am pretty new to processing swift messages in java, I am trying with prowide-iso20022 software java library to parse the SwiftMX messages (https://github.com/prowide/prowide-iso20022)
I want to extract UETR (OrgnlUETR) of a message and other similar required information from the message, these field I think can be in different locations/hierarchy in xml for different type of message (i.e no common hierarchy). Need help in how to extract the required fields, since there are lot type of messages in SwiftMX
Below is the sample/dummy SwiftMX message for reference.
<SwiftMx>
<Header>
<DestinationID>ABC</DestinationID>
<SenderID>PQR</SenderID>
<OperationOrganizationID/>
<MessageType>ISO22IN</MessageType>
<DateSent>20200321</DateSent>
<TimeSent>0829</TimeSent>
<MessageID>3190eee</MessageID>
</Header>
<SubHeader>
<ReceiverAddress>ZYDFUS562WW</ReceiverAddress>
<SenderAddress>NCBACATEEE</SenderAddress>
</SubHeader>
<Body>
<ISOMessage>
<AppHdr>
<Fr>
<FIId>
<FinInstnId>
<BICFI>NCBACATEEE</BICFI>
</FinInstnId>
</FIId>
</Fr>
<To>
<FIId>
<FinInstnId>
<BICFI>ZYDFUS562WW</BICFI>
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>IMDLC6928</BizMsgIdr>
<MsgDefIdr>camt.029.001.09</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2010-09-31T04:49:45+03:00</CreDt>
</AppHdr>
<Document>
<RsltnOfInvstgtn>
<Assgnmt>
<Id>IMDLC69S01</Id>
<Assgnr>
<Agt>
<FinInstnId>
<BICFI>SNDRCAXX</BICFI>
</FinInstnId>
</Agt>
</Assgnr>
<Assgne>
<Agt>
<FinInstnId>
<BICFI>SNDXX</BICFI>
</FinInstnId>
</Agt>
</Assgne>
<CreDtTm>2010-09-29T04:49:45+03:00</CreDtTm>
</Assgnmt>
<Sts>
<Conf>RJCR</Conf>
</Sts>
<CxlDtls>
<TxInfAndSts>
<CxlStsId>TESTID</CxlStsId>
<RslvdCase>
<Id>123</Id>
<Cretr>
<Pty>
<Nm>XYZ LTD</Nm>
<Id>
<OrgId>
<AnyBIC>SNDRCAXXX</AnyBIC>
</OrgId>
</Id>
<CtryOfRes>IN</CtryOfRes>
</Pty>
</Cretr>
</RslvdCase>
<OrgnlGrpInf>
<OrgnlMsgId>YT123</OrgnlMsgId>
<OrgnlMsgNmId>IEUW79</OrgnlMsgNmId>
</OrgnlGrpInf>
<OrgnlUETR>9de-aed0-16487c27b42d</OrgnlUETR>
</TxInfAndSts>
</CxlDtls>
</RsltnOfInvstgtn>
</Document>
</ISOMessage>
</Body>
<Timestamp>
<Date>20200327</Date>
<Time>123424</Time>
</Timestamp>
</SwiftMx>
Not able to parse using below abstract class, getting null returned from parse method
parse into generic structure AbstractMX mx = AbstractMX.parse(xml);
I want to know the type of message which I was able to extract using below code.
MxSwiftMessage mxSwiftMessage = MxSwiftMessage.parse(xml); String msgDefIdr = ((BusinessAppHdrV01) mxSwiftMessage.getAppHdr()).getMsgDefIdr();
But this is working only for AppHdr, not sure how to parse when we have differently structured messages.