I have created a single instance codeunit based on the "Say Hello to the World" article but when I try to add functionality that should save imported xmls to a BLOB field I get an error message which says: "You could not stream to BLOB" and then "This message is for C/AL programmers: The call to member save failed. msxml3.dll returned the following message: The xml-document must have an element on top level.
I am using the freeware application QReader MSMQ Viewer v2.0.0 to send a very simple xml message to the message queue:
<?xml version="1.0">
<string>Hello, world!</string>
I have also tried just with this as the text sent:
<string>Hello, world!</string>
The codeunit in Navision looks like this:
OnRun()
MessageQueueNameIn := 'localhost\private$\test_in';
MessageQueueNameOut := 'localhost\private$\test_out;
CREATE(XMLDom);
CREATE(MQBus);
CREATE(CC2);
CC2.AddBusAdapter(MQBus,1);
MQBus.OpenReceiveQueue(MessageQueueNameIn,0,0);
CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
InMsg := InMessage;
InS := InMsg.GetStream();
XMLDom.load(InS);
IF TempDoc.FIND('+') THEN
TempDoc."No." := TempDoc."No." + 1
ELSE
TempDoc."No." := 1;
TempDoc.INIT;
TempDoc.INSERT;
TempDoc."XML Document".CREATEINSTREAM(InS);
XMLDom.save(InS);
TempDoc.MODIFY;
And the variables are created like this (I have also tried with different versions of the XMLDOM automations):
Name DataType Subtype Length
MQBus Automation 'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter
CC2 Automation 'Navision Communication Component version 2'.CommunicationComponent
InMsg Automation 'Navision Communication Component version 2'.InMessage
InS InStream
XMLDom Automation 'Microsoft XML, v3.0'.DOMDocument
XMLNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
OutMsg Automation 'Navision Communication Component version 2'.OutMessage
OutS OutStream
TempDoc Record O2 XML Document Queue
Is the error related to the C/AL code or should I use another xml example og another application to send the xml to the MSMQ to make sure it is received in the Queue as an XML and not a text ?
0
Answers
I tried to use a different application which is sending the xml to the MSMQ and with the same C/AL code it works just fine :-)