Sending MSMQ messages works just fine with 'Microsoft Message Queue 3.0 Object Library' automation object but there are problems with the body of received message which always seems to be empty. Neither DOMDocument type body nor text type body does not seem to work. I am using the following code to receive the message:
varTransaction := 0;
varWantDestinationQueue := 0;
varWantBody := 1;
varReceiveTimeOut := 30000;
varWantConnectorType := 0;
ReceiveMessage := ReceiveQueue.Receive(
varTransaction,
varWantDestinationQueue,
varWantBody,
varReceiveTimeOut,
varWantConnectorType);
0
Comments
RIS Plus, LLC
When reading MSDOM object (I am using 'Microsoft XML, v3.0'.DOMDocument Automation variable) with FORMAT(Message.Body)) gives the following error:
"This data type is not supported by C/SIDE. You can access data from any of the following data types VT_VOID, VT_I2,..."
Reading text variant with FORMAT(Message.Body)) just gives an empty string.
MyMessage is 'Microsoft Message Queue 3.0 Object Library'.MSMQMessage
If this doesn't work then I'd suggest you revise the code that sends the message to make sure the body of the message body contains either a string or an MSDOM object.
RIS Plus, LLC
If body is text (In computer management / message queuing it looks like this: 54 00 45 00 53 00 54 00 T.E.S.T.) I don't get any errors. After loadXML(MyVariant) I try MSDOM.Save but I only get empty xml file.
If body is xml object like this
(
11 0F D9 F6 73 9C D3 11 B3 ..ÙösœÓ.³
2E 00 C0 4F 99 0B B4 3C 78 ..ÀO™.´<x
6D 6C 3E 3C 6F 75 74 3E 3C ml><out><
6C 6F 63 61 74 69 6F 6E 3E location>
3C 78 63 6F 6F 72 64 3E 33 <xcoord>3
33 32 38 34 33 33 3C 2F 78 328433</x
63 6F 6F 72 64 3E 3C 79 63 coord><yc
6F 6F 72 64 3E 36 38 32 35 oord>6825
30 35 31 3C 2F 79 63 6F 6F 051</ycoo
72 64 3E 3C 2F 6C 6F 63 61 rd></loca
74 69 6F 6E 3E 3C 2F 6F 75 tion></ou
74 3E 3C 2F 78 6D 6C 3E 0D t></xml>.
0A) .
I get the following error with load:
"Could not invoke the member load.... The number of elements provided is different from the number of arguments accepted by the method or property".
The dots between the letters is because the text string is encoded as a double byte character stream, and the LoadXML method should be able to handle that.
RIS Plus, LLC
Actually it looks like MyVariant is always empty no matter what I send to the queue.
I can send xml as double byte text but MyVariant is still empty.
RIS Plus, LLC
If you set a SQL Server field to data type text, Navision will not recognize it. You try to assign a SQL Server type text to a text field in NAV, it will error out.
I know there are many types of strings in C++, and you're going to have to try each one of them until you find the one that NAV recognizes as a text variable. Then, you can put XML inside the string and load it into an MSDOM object using the LoadXML method.
RIS Plus, LLC
varTransaction := 0;
varWantDestinationQueue := 0;
varWantBody := 1;
varWantConnectorType := 0;
[-X
when they should have been like this:
varTransaction := false;
varWantDestinationQueue := false;
varWantBody := true;
varWantConnectorType := false;
Thanks for the help anyway. It works now. \:D/
Good job making that work.
RIS Plus, LLC
REPEAT
ReceiveMessage := ReceiveQueue.Receive(
varTransaction,
varWantDestinationQueue,
varWantBody,
varReceiveTimeOut,
varWantConnectorType);
UNTIL ReceiveMessage.CorrelationId = SendMessage.Id;
But code above does not work because Ids that are variants cannot be compared with = operator. Is there a way to compare them in Navision? (FORMAT() does not work.)
RIS Plus, LLC
RIS Plus, LLC
RIS Plus, LLC
So i guess 'correlation id' must be handled somehow within the xml object in the message body then...