XMLPorts and MSMQ Bus adapter

nstoevnstoev Member Posts: 7
Hi,

I've been trying to get MSMQ Bus Adapter to work with XML Port instead of MSXML DOM automation objects but I seem to have a problem with detection of the End of stream.

The problem is as follows:
----
ComCom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")

InMsg := InMessage;
InS := InMsg.GetStream();

InXMLPort.SETSOURCE(InS);
InXMLPort.IMPORT;
----
For this code snippet I get an XML Parser error that the text/xml portion cannot exist more than once. I suspected that the stream is not closed properly and is read repeatedly by the XMLPort import.

The same code works fine if I substitute the last two lines with XMLDom.load(InS); where XMLDom is a MSXML DOM automation object.

I tried loading the stream into a BigText variable and this caused Navision to get into a loop and eventually to crash due to lack of memory (the memory was quickly increasing until it took up all of my RAM).

So has anybody seen a similar situation or has anybody succeded in loading a MSMQ stream into an XMLPort ?

Nikolai

Comments

  • DenSterDenSter Member Posts: 8,307
    I don't know why the stream isn't accepted, doesn't make sense does it. I use a DOMdocument object to set the XMLPort source, like this:
    TempBlob.Blob.CREATEOUTSTREAM(outstr);
    XMLDOMDocument.save(outstr);
    TempBlob.Blob.CREATEINSTREAM(instr);
    ImportInboundItem.SETSOURCE(instr);
    ImportInboundItem.IMPORT;
    
    The TempBLOB variable is a temporary TempBlob record, which is useful for BLOB and stream manipulation, since BLOB is not a variable datatype.

    I also wrote an integration piece where I use the Message Queing object model directly, but in that case I also use a DOMDocument object for the XML. I guess it's what I know and I never felt the need to do it any other way.
  • nstoevnstoev Member Posts: 7
    I think this must be a bug of some sort with the XMLPorts and I was thinking of sending it to Microsoft. It would make sense to use XMLPorts which are supposedly much faster than the MSXML DOM.

    Tell me, if I use the MSMQ COM object model directly, are there suitable events for incoming messages and how is the performance compared to the MSMQ Bus Adapter.
  • DenSterDenSter Member Posts: 8,307
    No it's not a bug in the XMLPort, the Navision MSMQ-Bus Adapter is not capable to process double byte characters (like unicode) in some situations. For some reason the DOMDocument object does, so in that case it imports correctly. In double byte encoding, there's a part of the character streams that makes the single byte stream think it is EOS, or something like that.

    I don't think reporting this to MS will make any difference.

    There is no message received event in the MSMQ object model that I know of. I think you asked the same question in another post.
  • pberbpberb Member Posts: 31
    Did anyone ever figure out what terminating character(s) the XMLport is expecting to work properly with the original example in this post?

    I couldn't get DenSter's code (above) to work -- gives an automation variable has not been instantiated error; and when that's fixed by adding a CREATE, it still doesn't put any value into the blob to pass to the XMLport.
  • DenSterDenSter Member Posts: 8,307
    That was just a 5 line code snippet that I copied out of a solution, of course it's not going to work independently. What is it that you are trying to do?
  • pberbpberb Member Posts: 31
    Hi Daniel,

    Tried actually calling you about this several times, but you never pick up. You are welcome to call me. I'm trying to XMLimport a message from the MS-Message queue into a Navision table.

    Pretty much as the original poster said, the XML parser seems to have a problem detecting the End of Stream using his specified code. With it, I get the error:

    "The XML Parser return the following fatal error:

    Illegal xml character."

    Line Number = 28 Column Number = 12"

    Using XML:

    Outs.WRITE('<?xml version="1.0" encoding="utf-8"?>' + FORMAT(CR) + FORMAT(LF) +
    '<Products>' + FORMAT(CR) + FORMAT(LF) +
    ' <Product>' + FORMAT(CR) + FORMAT(LF) +
    ' <CategoryId>16725</CategoryId>' + FORMAT(CR) + FORMAT(LF) +
    ' <PriceMSRP>0</PriceMSRP>' + FORMAT(CR) + FORMAT(LF) +
    ' <PriceLevel1>9.5000</PriceLevel1>' + FORMAT(CR) + FORMAT(LF) +
    ' <PriceLevel2>0</PriceLevel2>' + FORMAT(CR) + FORMAT(LF) +
    ' <PriceLevel3>0</PriceLevel3>' + FORMAT(CR) + FORMAT(LF) +
    ' <Quantity>140</Quantity>' + FORMAT(CR) + FORMAT(LF) +
    ' <WebEnabled>False0</WebEnabled>' + FORMAT(CR) + FORMAT(LF) +
    ' <Description />' + FORMAT(CR) + FORMAT(LF) +
    ' <Description2 />' + FORMAT(CR) + FORMAT(LF) +
    ' <Description3 />' + FORMAT(CR) + FORMAT(LF) +
    ' <Description4 />' + FORMAT(CR) + FORMAT(LF) +
    ' <Weight>0</Weight>' + FORMAT(CR) + FORMAT(LF) +
    ' <Status>Active</Status>' + FORMAT(CR) + FORMAT(LF) +
    ' <TaxGroupId>0</TaxGroupId>' + FORMAT(CR) + FORMAT(LF) +
    ' <IsTaxable>False</IsTaxable>' + FORMAT(CR) + FORMAT(LF) +
    ' <RemoteSync>5/24/2006 7:37:11 AM</RemoteSync>' + FORMAT(CR) + FORMAT(LF) +
    ' <CentralSync />' + FORMAT(CR) + FORMAT(LF) +
    ' <PriceBase>9.9900</PriceBase>' + FORMAT(CR) + FORMAT(LF) +
    ' <Id>148414</Id>' + FORMAT(CR) + FORMAT(LF) +
    ' <RemoteId>121.4</RemoteId>' + FORMAT(CR) + FORMAT(LF) +
    ' <Name>Football</Name>' + FORMAT(CR) + FORMAT(LF) +
    ' <LookupCode>15100</LookupCode>' + FORMAT(CR) + FORMAT(LF) +
    ' <NoDiscount>False</NoDiscount>' + FORMAT(CR) + FORMAT(LF) +
    ' </Product>' + FORMAT(CR) + FORMAT(LF) +
    '</Products>');

    I’m guessing an answer is to use an end-of-stream or end-of-file character(s) that the XML parser will recognize might be all we really need to make it work, so I've tried adding several different control characters at the end of the XML stream to attempt to signify the EOS. But no matter what I've tried or how long the stream is, it always errors the same way one character after the last one.

    Only those that have the XML parser code would be able to say whether or not the XML parser is expecting an EOS character(s) marker, and if so, what it/they are (the parser might use another way to identify the EOS/EOF).

    Is there a way to reach a programmer that has access to the core Navision code? (specifically, the XML parser). Any core Navision Denmark programmers on this forum?

    Many thanks,
    Paul
  • DenSterDenSter Member Posts: 8,307
    Hi Paul,

    Nice talking to you :). You might also want to try building your XML with an MSDOM object instead of writing directly to the stream. When you save this MSDOM object to a stream it knows how to do that.
Sign In or Register to comment.