Options

Retrieving MSMQ message

sbhamidisbhamidi Member Posts: 22
Hello,
I'm trying to retrieve messages from the MSMQueue in Navision. I create the messages in ASP. Here's my Navision code
[u]OnRun()[/u]
IF ISCLEAR(Comcom) THEN
  CREATE(Comcom);
IF ISCLEAR(MQBus) THEN
  CREATE(MQBus);
IF ISCLEAR(XMLDoc) THEN
  CREATE(XMLDoc);

Comcom.AddBusAdapter(MQBus,1);
MQBus.OpenReceiveQueue('edi\private$\myq',1,1);

[u]FindNode(RootNode : Automation "'Microsoft XML, v3.0'.IXMLDOMNode";XMLNode : Automation "'Microsoft XML, v3.0'.IXMLDOMNode") XmlString [/u]
CLEAR(XMLNode);
XMLNode := RootNode.selectSingleNode('string');
IF ISCLEAR(XMLNode) THEN
  XmlString := ''
ELSE
  XmlString := XMLNode.text;

[u]Comcom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")[/u]
InMsg := InMessage;
InStr := InMsg.GetStream;

XMLDoc.load(InStr);
Line := FindNode(XMLDoc,XMLDoc);

MESSAGE(Line);

The function Comcom::MessageReceived is supposed to receive the messages from MSMQ. But when the "InStr := InMsg.GetStream" is executed, a blank value is assigned.
Now this works perfectly if the message was created within Navision itself and sent to MSMQ - so I'm perplexed.
Any help would be greatly appreciated.

Comments

  • Options
    DenSterDenSter Member Posts: 8,304
    Your MSMQ message must have a label "Navision MSMQ-BA" in order for the Navision MSMQ adapter to pick it up. When you send a message with Navision, the adapter adds the label for you, but if you program the message outside of Navision you have to program it yourself.
  • Options
    sbhamidisbhamidi Member Posts: 22
    Hello,
    Thanks for the response. I do have that label. I had already researched that part. Any more ideas?
    Thanks in advance
  • Options
    DenSterDenSter Member Posts: 8,304
    Do you send an MSDOM object into the queue? I couldn't get a regular XML string to work, and when I changed it to an MSDOM object it worked.
  • Options
    sbhamidisbhamidi Member Posts: 22
    In my ASP page, I'm actually creating an xml string like this -
    <order><no>12345</no></order>
    And then I'm just sending this string to the MSMQ. I'm not really sending an XML doc. Maybe I should try the same thing you did. I will keep you posted. I will get a chance to know by wednesday.
    I really appreciate your suggestion.
    Thanks
  • Options
    sbhamidisbhamidi Member Posts: 22
    I have made the change to send an XMLDOM object to the MSMQ. It still does not work. I had MBS support take a look at the code. It works on their end. I even had them shadow my desktop.
    The only difference they said was that the message in the Queue on their end has the XML version in front of the actual xml data. On my end, it's a bunch of special characters before the xml data.
    MBS support guy used a C# form to generate the xml message. They used the following, where mqFromNavision is the message queue object:
    mqFromNavision.Formatter = new
          System.Messaging.XmlMessageFormatter(new Type[] {typeof(String)});
    
    ASP does not have the method they're using. Has anyone worked on a similar problem? Please help!
    Thanks in advance
  • Options
    jorgecphjorgecph Member Posts: 26
    What type of special characters? Could it be that your text is actually unicoded? MSDN - Byte-order Mark.

    Have you had XMLDom given you the reason why it complains?
    XMLDoc.load(InStr);
    
    IF (XMLDoc.parseError.errorCode <> 0) THEN
    BEGIN
       myErr := XMLDoc.parseError;
       MESSAGE('You have error ' + myErr.reason + ' - ' + myErr.srcText + '-' + FORMAT(myErr.linepos));
    END;
    

    Can you share the characters that you are trying to load?


    Br,

    Jorge
    _________________
    “This posting is provided "AS IS" with no warranties, and confers no rights.”
Sign In or Register to comment.