Skip to content

Instantly share code, notes, and snippets.

Avatar

Ilia Saunkin esaounkine

  • London, UK
View GitHub Profile
@esaounkine
esaounkine / ValidateMTTest.java
Created Mar 14, 2014
parsing and validation an MT (more examples http://wiki.datamation.gr/x/OIBH)
View ValidateMTTest.java
protected void testMessage(String messageContent) throws InvalidMessageFormatException {
//parse message string to the SwiftMessage object
SwiftMessage message = new SwiftMsgProcessor().ParseMsgStringToObject(messageContent);
//validate SwiftMessage (parsed from String or built programmatically)
SwiftMsgValidator validator = new SwiftMsgValidator();
SwiftValidObj validation = validator.validateMsg(message);
//swift mt text
String mtMessageText = validation.getMessage();
//obtain list of errors from the validation object
@esaounkine
esaounkine / Msg103.java
Created Mar 10, 2014
build MT103 using bare methods (more examples at http://wiki.datamation.gr/x/OIBH)
View Msg103.java
public SwiftMessage buildMT103() {
SwiftMessage message = new SwiftMessage();
// Set Tags for block1
message.setArgApplid("F");
message.setArgServid("01");
message.setArgLTaddrBlk1("COPZBEB0AXXX");
// Set Tags for block2
message.setArgInoutind("O");
@esaounkine
esaounkine / Msg103.java
Last active Aug 29, 2015
build MT103 using additional methods (more examples at http://wiki.datamation.gr/x/OIBH)
View Msg103.java
public SwiftMessage buildMT103() {
SwiftMessage message = new SwiftMessage();
// Set Tags for block1
message.setArgApplid("F");
message.setArgServid("01");
message.setArgLTaddrBlk1("COPZBEB0AXXX");
// Set Tags for block2
message.setArgInoutind("O");
@esaounkine
esaounkine / MxMessageProcessingService.java
Created Jan 28, 2014
code snippet to parse XML string into a valid MX message object
View MxMessageProcessingService.java
public Message parseMessage(String msgText) throws Exception {
String namespace = msgText.replaceAll("(?s).*?xmlns=\"(.*?)\".*", "$1");
return CoreMessage.parseXML(msgText, namespace);
}
@esaounkine
esaounkine / SampleMessageCreation.java
Last active Jan 2, 2016
sample code to create SWIFT MT 205COV using the Datamation SMV (more examples at http://wiki.datamation.gr/x/OIBH)
View SampleMessageCreation.java
@Test
public void testCreating205COV() {
SwiftMessage message = new SwiftMessage();
// Set Tags for block1
message.setArgApplid("F");
message.setArgServid("01");
message.setArgLTaddrBlk1("AAAABEBBAXXX");
// Set Tags for block2
View ValidateMTTest.java
SwiftMessage message = new SwiftMsgProcessor().ParseMsgStringToObject(messageContent);
SwiftMsgValidator validator = new SwiftMsgValidator(DEFAULT_CRLF);
SwiftValidObj validation = validator.validateMsg(message);
for(ValidationError error : validation.getValidationErrorList()) {
System.out.println(error.getTagName() + " => " + error.getDescription());
}
@esaounkine
esaounkine / SepaMessageProcessingService.java
Last active Dec 27, 2015
pacs 008 001 auto reply with 004
View SepaMessageProcessingService.java
//Initialize a payment return (pacs.004)
PaymentReturn paymentReturn = new PaymentReturn();
//message id is commonly auto-generated by each system
paymentReturn.set_GrpHdr_MsgId("OURMESSAGEID");
//The settlement date for our return
paymentReturn.set_GrpHdr_IntrBkSttlmDt(Calendar.getInstance());
//In most cases this is set to CLRG...
paymentReturn.set_GrpHdr_SttlmInf_SttlmMtd("CLRG");
//and Clearing system is set to ST2
paymentReturn.set_GrpHdr_SttlmInf_ClrSys_Prtry("ST2");
@esaounkine
esaounkine / SepaMessageProcessingService.java
Last active Dec 27, 2015
pacs 008 001 auto reply with 056
View SepaMessageProcessingService.java
//Initialize a request for recall message (camt.056) with default values
FIToFIPaymentCancellationRequest fiToFIPaymentCancellationRequest = new FIToFIPaymentCancellationRequest(
"GENERATEDASSIGNMENTID", // the assignment id
"XXXXXBIC", // the assigner bank BIC
"YYYYYBIC" // the assignee bank BIC
);
//Construct the message reply information
//Here we are requesting a recall for a message with reason code DUPL (dulicate sending)
Vector<MsgReplyInfo> msgReplyInfo = new Vector<MsgReplyInfo>();
ReasonCode rc = new ReasonCode(ReasonCode.CD, "DUPL", null, null);
View SepaMessageProcessingService.java
FIToFICustomerCreditTransfer fiToFICustomerCreditTransfer = new FIToFICustomerCreditTransfer();
fiToFICustomerCreditTransfer.parseMessageFromXML(msgText);
List<String> validationErrors = fiToFICustomerCreditTransfer.validate();
@esaounkine
esaounkine / IndexController.java
Created Oct 14, 2013
validate SWIFT message example
View IndexController.java
SwiftMessage parsedMessage = swiftMessageProcessingService.parseSwiftMessage(messageText);
SwiftValidObj validatedMessage = swiftMessageProcessingService.validateSwiftMessage(parsedMessage);
//validatedMessage will contain the SWIFT message object and text, as well as error message in case the message is not valid
You can’t perform that action at this time.