This feature gives the conversion back and forth between SWIFT object model and an XML representation.
The XML schema is a non standard internal representation.
The following examples show the supported xml schema. It is a basically a linear mapping of the SWIFT message structure.
<message> <block1> <applicationId>F</applicationId> <serviceId>01</serviceId> <logicalTerminal>BANKBEBBAXXX</logicalTerminal> <sessionNumber>2222</sessionNumber> <sequenceNumber>123456</sequenceNumber> </block1> <block2 type="input"> Â <messageType>100</messageType> <receiverAddress>BANKDEFFXXXX</receiverAddress> <messagePriority>U</messagePriority> <deliveryMonitoring>3</deliveryMonitoring> </block2> <block4> <tag> <name>23G</name> <value>NEWM</value> </tag> <tag> <name>339</name> <value>CAT09U</value> </tag> <tag> <name>344</name> <value>U3</value> </tag> <tag> <name>345</name> <value>810895896898899900910920935940</value> </tag> <tag> <name>339</name> <value>CMMN12</value> </tag> </block4> </message>
Â
Notice in the above example that the <obsolescencePeriod> tag was intentionally ommited. This is the proper treatment for optional fields in block 1 and block 2 that are not present in the particular message being represented. If a block 1 or block 2 field is present it must have the correct field length according to SWIFT. For example this tag: <obsolescencePeriod>null</obsolescencePeriod> will generate an exception.
An example with an output block 2, where you can see how the MIR field is split in several tags:
<message> Â <block1> Â <applicationId>F</applicationId> Â <serviceId>01</serviceId> Â <logicalTerminal>BANKBEBBAXXX</logicalTerminal> Â <sessionNumber>2222</sessionNumber> Â <sequenceNumber>123456</sequenceNumber> Â </block1> Â <block2 type="output"> Â <messageType>100</messageType> Â <senderInputTime>1200</senderInputTime> Â <MIRDate>970103</MIRDate> Â <MIRLogicalTerminal>BANKBEBBAXXX</MIRLogicalTerminal> Â <MIRSessionNumber>2222</MIRSessionNumber> Â <MIRSequenceNumber>123456</MIRSequenceNumber> Â <receiverOutputDate>970103</receiverOutputDate> Â <receiverOutputTime>1201</receiverOutputTime> Â <messagePriority>N</messagePriority> Â </block2> </message>
The main access point to these features are the class XMLParser and the XMLWriterVisitor, but the simplest way to use this feature is by means of the ConversionService API:
IConversionService srv = new ConversionService();
SwiftMessage msg = new SwiftMessage(); SwiftBlock1 b1 = new SwiftBlock1(); b1.setApplicationId("F"); b1.setServiceId("01"); b1.setLogicalTerminal("BICFOOYYAXXX"); b1.setSessionNumber("1234"); b1.setSequenceNumber("123456"); msg.setBlock1(b1);
//gets the xml representation of the constructed message String xml = srv.getXML(msg);
//gets a message object from a given xml String xml2 = "<message>...</message>"; SwiftMessage msg2 = srv.getMessageFromXML(xml2);
|