MSMQ Formatter and XmlMessageFormatter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chizl

    MSMQ Formatter and XmlMessageFormatter

    On the MQReceiveComple ted method below, I get an error "Name cannot begin
    with the '.' character, hexadecimal value 0x00. Line 1, position 40."..
    This data is XML that I'm putting into this queue.
    ---------
    <?xml version=""1.0""
    encoding=""utf-8""?><DATA><FIE LD1>CHIZL</FIELD1><FIELD2> DA
    MAN</FIELD2></DATA>
    ---------

    Methods
    ---------------------
    public void SetupMSMQ()
    {
    String szMQPath = @".\private$\Te stQueue";

    if (!MessageQueue. Exists(szMQPath ))
    MessageQueue.Cr eate(szMQPath);

    //setup MQ Request Path
    MessageQueue mq = new MessageQueue(sz MQPath);
    //format of message will be XML

    mq.Formatter = new XmlMessageForma tter(new Type[] { typeof(String) });
    //vs..
    //((XmlMessageFor matter)mq.Forma tter).TargetTyp eNames = new string[] {
    "Data" };

    //setup async call
    mq.ReceiveCompl eted += new
    ReceiveComplete dEventHandler(M QReceiveComplet ed);
    //callback ready
    mq.BeginReceive ();

    ...
    ...
    }


    private static void MQReceiveComple ted(Object source,
    ReceiveComplete dEventArgs asyncResult)
    {
    //connect to the queue.
    MessageQueue mq = (MessageQueue)s ource;
    //end the asynchronous Receive operation.
    System.Messagin g.Message m = mq.EndReceive(a syncResult.Asyn cResult);
    //display message information on the screen.
    String szXML = (String)m.Body; //Fails
    ....
    }

    --
    /*Chizl*/


  • Mufaka

    #2
    Re: MSMQ Formatter and XmlMessageForma tter

    I vaguely recall having to use a BinaryFormatter when reading queue
    items inserted by another language. You can try that and just get the
    message body as a string.

    Chizl wrote:
    I think I know the problem, when I write it to the queue, I'm using VBS and
    I noticed in the queue the data is in Unicode. So how do I get it to write
    as ASCII?
    >

    Comment

    • =?Utf-8?B?RGFuIEtlbGxleQ==?=

      #3
      Re: MSMQ Formatter and XmlMessageForma tter

      For what it is worth I believe you mean the ActiveXFormatte r, which should be
      used when receiving messages sent by non .Net applications, for exmaple VB6
      applications.

      "Mufaka" wrote:
      I vaguely recall having to use a BinaryFormatter when reading queue
      items inserted by another language. You can try that and just get the
      message body as a string.
      >
      Chizl wrote:
      I think I know the problem, when I write it to the queue, I'm using VBS and
      I noticed in the queue the data is in Unicode. So how do I get it to write
      as ASCII?
      >

      Comment

      Working...