Question

I'm trying to fix a problem with an application that sends a message to the SWIFT network. The application is a .NET application and it uses IBM's amdqmdnet.dll assembly to communicate with the WebSphere MQ server. On the WebSphere MQ server the SWIFT Alliance software is running.

The messages are sent from the application, but does not enter the SWIFT network. Some investigation has revealed the following error message:

MQSeries Queue 'MQSWIFT/SWIFT.SENDER', Nbr 123, Session 4567, Sequence 890, Conversion error (From)
    MQ Msg Id    : AMQ MQSWIFT     <XX><XX><XX>X <X>-<XX>
    Message Info : Error in FIN block 1: can not find tag F01 in message
{.1.:.F.0.1. (rest of message removed)

The start of the message sent is {1:F01 and to me this looks like the message is encoded in UNICODE (UTF-16) but the SWIFT software expects ASCII. The SWIFT software sees {.1.:.F.0.1..

My question is: How do I send the message to the WebSphere MQ queue using ASCII encoding?

The connection has the properties MQC.TRANSPORT_PROPERTY, MQC.HOST_NAME_PROPERTY and MQC.CHANNEL_PROPERTY set.

The queue is opened using the options MQC.MQOO_OUTPUT and MQC.MQOO_FAIL_IF_QUIESCING.

The message is created using the format MQC.MQFMT_STRING and default put message options:

var mqMessage = new MQMessage { Format = MQC.MQFMT_STRING };
mqMessage.WriteString(swiftMessage);
var mqMessageOptions = new MQPutMessageOptions();
queue.Put(mqMessage, mqMessageOptions);

I have noticed that the MQC enumeration has the value CODESET_819 which probably refers to ASCII but I have no idea if I need to use it and how.

Was it helpful?

Solution

The solution that worked for me was to set the CharacterSet property of the MQMessage to 819:

var mqMessage = new MQMessage {
  Format = MQC.MQFMT_STRING,
  CharacterSet = 819
}
mqMessage.WriteString(swiftMessage);

A collegaue also told me that I should be able to use the MQMessage.Write overload that accepts a byte array. Something along these lines:

var mqMessage = new MQMessage();
mqMessage.Write(Encoding.ASCII.GetBytes(swiftMessage));

However, I have not verified that this alternative approach works.

OTHER TIPS

I believe the SWIFT app will convert to ASCII after it reads from the queue.

So, what you need to do:

Either write ASCII to the MQ message: Change encoding in your .Net app to make 'swiftMessage' ASCII encoded.

Or change codeset 819 to whatever encoding the data actually is, which you say is UTF-16, so that would be codeset 1200.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top