MSMQ example does not work!?!

dr.burns
Member Posts: 6
Hello,
I try to get the example from:
http://msdn.microsoft.com/library/defau ... vision.asp
to work, but I get two error messages:
The 1st error message I get is:
'The stream has returned a read error'
followed by
'This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it'
If I replace the line:
XMLDom.load (InS); by: XMLDom.load (InMsg.GetStream());
it works. So why does this happen in example code from Microsoft?
The 2nd problem I cannot solve is that the error message:
'This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it'
comes up at a different line also!
I run the debugger and everything works fine until following line:
OutS.WRITE(XMLDom.xml);
But I just copied the example code from the Microsoft site!
Does anybody have an idea whats going wrong?
I already instanitated the vars in the OnRun triger of my codeunit as mentioned under the MS example.
Any help would be highly appreciated! Thanks in advance!
dr.burns
I try to get the example from:
http://msdn.microsoft.com/library/defau ... vision.asp
to work, but I get two error messages:
CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH") // get the message InMsg := InMessage; InS := InMsg.GetStream(); // load the message into an XML document and find a node XMLDom.load (InS); // <-- 1st ERROR XMLNode := XMLDom.selectSingleNode ('string'); // open the response queue and create a new message MQBus.OpenWriteQueue('.\fromNavision',0,0); OutMsg := CC2.CreateoutMessage('Message queue://.\fromNavision'); OutS := OutMsg.GetStream(); // build the contents of your message XMLNode.text := UPPERCASE (XMLNode.text); // fill the message and send it OutS.WRITE(XMLDom.xml); // <-- 2nd ERROR OutMsg.Send(0);
The 1st error message I get is:
'The stream has returned a read error'
followed by
'This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it'
If I replace the line:
XMLDom.load (InS); by: XMLDom.load (InMsg.GetStream());
it works. So why does this happen in example code from Microsoft?
The 2nd problem I cannot solve is that the error message:
'This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it'
comes up at a different line also!
I run the debugger and everything works fine until following line:
OutS.WRITE(XMLDom.xml);
But I just copied the example code from the Microsoft site!
Does anybody have an idea whats going wrong?
I already instanitated the vars in the OnRun triger of my codeunit as mentioned under the MS example.
Any help would be highly appreciated! Thanks in advance!
dr.burns
0
Comments
-
The error comes from the fact that you have not instantiated the XMLDom object. Try adding the following at the beginning of the event, before any other reference to the XMLDom object:
IF NOT ISCLEAR(XMLDom) THEN CLEAR(XMLDom); CREATE(XMLDom);
After you added this, the XMLDom.load(InS) should work.
I don't know why else the Instream stuff would be erroring out on you. If it is still erroring out on you, check the variable types. The InMsg should be a 'Navision Communication Component version 2'.InMessage object, and the Ins variable should be an InStream variable.
Then, to load the xml into the outstream, instead ofOutS.WRITE(XMLDom.xml); OutMsg.Send(0);
you do this:XMLDom.save(OutS); OutMsg.Send(0);
I don't know if your other XML code will work though, as your XMLNode isn't loaded back into your XMLDom object. I haven't tested it the way you wrote this. You can check the standard Navision Biztalk codeunits for great examples of XML document building.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions