MQMessage queueMessage = new MQMessage();
queueMessage.WriteString(strInputMsg);
queueMessage.Format = MQC.MQFMT_STRING;
MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions();
Queue.Put(queueMessage, queuePutMessageOptions);
Using C#, with the above code, when I input the message into the queue, the data length of the message is 3600.
When I manually input the message into the queue by right clicking the queue and selecting Put Test Message option, the data length of the message is 1799.
I am really confused why this is the case. The message in both cases is an xml string with declaration. In Notepad++, there are 1811 characters including the declaration. When I view the message in debugger before I input into the queue, the message is converted into xml without any line or return carriages.
I created the xml string using:
//converts string message into xml by serializing it
public string GetMessage(MyMessage messageInstance)
{
// Serialize the request
XmlSerializer xsr = new XmlSerializer(typeof(MyMessage));
MemoryStream memoryStream = new MemoryStream();
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
xsr.Serialize(xmlTextWriter, messageInstance);
memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
string XmlizedString = new UTF8Encoding().GetString((memoryStream.ToArray());
// Encode the xml
Encoding utf = Encoding.UTF8;
byte[] utfBytes = utf.GetBytes(XmlizedString);
// Load the document (XmlResolver is set to null to ingore DTD)
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.XmlResolver = null;
xmlDoc.LoadXml(utf.GetString(utfBytes));
return utf.GetString(utfBytes);
Am I missing anything in my C# implementation that is adding extra characters?
Thanks.