I am developing a web-based application that interacts with Navision via the MSMQ. It works beautifully, but I think that I may not be returning the XML response as efficiently as I could be. I am currently using the MSXML’s “save” method to output the response XML to disk. I then use a Navision FILE variable in binary mode to read the file back in and write it to the OutStream 1 byte at a time. My reasons for this are as follows: I can’t write the entire XML variable to the stream (MSXML.xml) because it can be quite large (~100k), and Navision can’t handle a variable that large. In addition, MSXML’s “save” method writes the XML file as a single line, so I need to read it back in binary mode (text mode will not read the complete line). If I use a larger binary variable (> 1 byte), my WHILE loop reads past the end of the file because Navision reads the number of bytes of the variable size, regardless of the file position. My basic question is this: what is the best way to send a large XML file to the MSMQ? Thank you for your help, Jonathan Cooper Software Architect AVF Consulting
Hi Jonathan, I think when you read bytes out of a file it returns the number of bytes actually read so there might be a way for you to increase the buffer size … Crisi
Thank you for the idea. I guess I can set the buffer to 2000 and check the return value from READ to see how many bytes were read. But I’d still like to find a way to accomplish this without writing the file out and reading it back in.
Hi Jonathan, Try using the Commerce Portal architecture, which is to monitor the MSMQ directly from Navision using events trigger by MSMQ. The XML document is received as an object and can be used directly. See codeunit 6221 - Request Handler for a sample. Note that the Commerce Portal solution uses a wrapper component to communicate with MSMQ. You probably would want to write your own wrapper component. Theoretically you should be able to work with the ‘Microsoft Message Queue x.x Object Library’ directly from Navision however I experienced problems with working with this automation controller directly and instead I created my own wrapper component which is working very well. See the link below for an example on how to work with MSMQ, there are several at MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msmq/msmq_using_intro_222b.asp Regards, Bruno
Hi, Bruno. Thank you for your reply. I am currently responding to events for the MSMQ. I can accept any size XML file. My problem is placing the response XML file back into the queue. If the file is too large (>1kb), Navision can’t handle retrieving the XML data from the MSXML automation controller. I am looking for a way for Navision to send a very large XML message to the MSMQ.
Hi Jonathan, This could be solved using the same approach as above, again see codeunit 6221 - Request Handler for an example: QueueHandler.SendToLabel(NASMgt.GetReqOutQueue,XMLDocOut,QueuePriority,NASMgt.GetReplyTimeOut,NASMgt.GetHKEYLOCALMACHINEReq,FALSE); Note that the above code sends the complete XML DOM (XMLDocOut) to the MSMQ wrapper component used by the Commerce Portal soultion. If my understanding of this is correct it is duable beacuse the XML DOM is sent as ByRef in VB terms (or VAR in Navision terms) and therefore only a pointer to the XML DOM is sent to the wrapper component which enables transmission of any size XML documents. Regards, Bruno
Hi, Bruno. Thanks for the tip. I wrote a COM object in C# that takes the stream and the XMLDOM object as input and simply sends the xml over the stream.