Receiving XML formated messages

Does anyone know how to receive XML formatted messages from MSMQ? Please advise. Thanks. Es

Install SDK and make yourself a codeunit for example in which you add Communication Component and the proper Bus Adapter (MQ :)) now… important is that you view the properties of the ComComp and set “WithEvents” to Yes… this will add a “function” in your object which is run each time a message arrives… Name DataType Subtype Length CC Automation ‘Navision Communication Component version 2’.CommunicationComponent MSMQBus Automation ‘Navision MS-Message Queue Bus Adapter’.MSMQBusAdapter But better yet… instead of listening to me gaggeling look at the development guide attach to the install of SDK… those that wrote that actually knows what they talk about… (unlike me :slight_smile: )

I would suggest you to read Communication Components Online Help located on Navision installation CD.

Only problem is that I don’t have the installation CD. I downloaded Navision off of the partner site. Are you referring to the devguide? I have read the devguide but still a little confused as to what needs to be done in order to receive XML formatted messages. The only thing that I have issues with is that, when XML comes into Navision and I transfer into a DOM document, it is empty. What is the problem? Anyone?

this code loads an xml file and sends it over my local MQ (Public) back to C:\ :slight_smile: Note: I run these from a form for tests where two buttons are doing fairly same things: IF CodeunitVar.RUN() THEN CodeUnitVar.SendXML(); etc… Oh… Codeunit presented below is SingleInstance… Documentation() OnRun() IF ISCLEAR(DOM3) THEN CREATE(DOM3); IF ISCLEAR(NCC2) THEN CREATE(NCC2); IF ISCLEAR(MSMQBus) THEN CREATE(MSMQBus); NCC2.AddBusAdapter(MSMQBus,1); MSMQBus.OpenReceiveQueue('.\ncc2_queue',0,2); SendHelloWorld() MSMQBus.OpenWriteQueue('.\ncc2_queue',0,2); NCC2OutMsg := NCC2.CreateoutMessage('Message queue://'); OutStr := NCC2OutMsg.GetStream(); OutStr.WRITETEXT('TXT'); OutStr.WRITETEXT('Hello World'); NCC2OutMsg.Send(0); SendXML() DOM3.load('c:\Add.xml'); MSMQBus.OpenWriteQueue('.\ncc2_queue',0,2); NCC2OutMsg := NCC2.CreateoutMessage('Message queue://'); OutStr := NCC2OutMsg.GetStream(); OutStr.WRITETEXT('XML'); DOM3.save(OutStr); NCC2OutMsg.Send(0); NCC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH") NCC2InMsg := InMessage; InStr := NCC2InMsg.GetStream(); InStr.READTEXT(Str,3); CASE Str OF 'TXT': BEGIN InStr.READTEXT(Str,MAXSTRLEN(Str)); MESSAGE(Str); END; 'XML': BEGIN IF DOM3.load(InStr) THEN MESSAGE(COPYSTR(DOM3.documentElement().baseName(),1,100)); DOM3.save('c:\Add2.xml'); END; ELSE MESSAGE('Unknown Message') END; NCC2InMsg.CommitMessage(); based on: Name DataType Subtype Length NCC2 Automation 'Navision Communication Component version 2'.CommunicationComponent MSMQBus Automation 'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter NCC2InMsg Automation 'Navision Communication Component version 2'.InMessage NCC2OutMsg Automation 'Navision Communication Component version 2'.OutMessage DOM3 Automation 'Microsoft XML, v3.0'.DOMDocument30 InStr InStream OutStr OutStream Str Text 30 var Variant

Navigera, Thanks for your reply. I will look to your code as a sample. You probably spent a lot of time on this and I really appreciate it.

You should also consider using the dll for Commerce Portal that monitors the Message Queue. The code already exists in Navision. Trace from where the NAS starts in Codeunit 1. It not only returns a DOM Document, it appends the GUID of the MSMQ Message.