NAS and VB.NET: Reading reply in .NET
dpardom
Member Posts: 74
Hi,
I have a working codeunit in navision, wich receives a xml, parse it, and send result back as reply.
Until here all right, but, when trying to read the reply from .NET it throws an "unexpected exception".
For msmq I'm using the navision dll's
The .NET code is:
At the end, comIn has as value something like "unexpected exception".
Help please. [-o<
I have a working codeunit in navision, wich receives a xml, parse it, and send result back as reply.
Until here all right, but, when trying to read the reply from .NET it throws an "unexpected exception".
For msmq I'm using the navision dll's
The .NET code is:
Dim ComCom As New NSCOMCOM2Lib.CommunicationComponent
Dim msmq As New MSMQBUSADAPTERLib.MSMQBusAdapter()
Dim m As MessageQueue
Dim comOut As NSCOMCOM2Lib.IOutMessage
Try
msmq.OpenWriteQueue(mstrPath, 0, 0)
msmq.OpenReceiveQueue(mstrPathReceive, 0, 0)
ComCom.AddBusAdapter(msmq, 0)
Catch ex As Exception
End Try
Dim enconding As Text.UnicodeEncoding
'information must be UTF8
Dim [Unicode] As Encoding = Encoding.GetEncoding("UTF-8")
Dim asciiBytes As Byte() = [Unicode].GetBytes(oPeticion.GenerarXML())
Try
Dim i As Integer
For i = 0 To asciiBytes.Length - 1
ci.RemoteWrite(asciiBytes(i), 1, 8)
Next
Catch ex As Exception
.......
End Try
Dim comIn As NSCOMCOM2Lib.IInMessage
Dim co As NSCOMCOM2Lib.IStream
Dim respuesta As Byte()
'Send XML to the queue and wait reply...
Try
comIn = comOut.SendWaitForReply(10000)
Catch ex As TimeoutException
Return False
Catch ex As Exception
Return False
End Try
At the end, comIn has as value something like "unexpected exception".
Help please. [-o<
0
Comments
-
Have you tried using any of the standard MSMQ components that come with .Net. (I'm assuming you're using VB.Net and not an older version of VB) Instead of using Navision's DLL's have you should consider using with the System.Messaging objects that are available in the base .Net classes.
There is lots of documentation on the internet to explain how these work. These classes also provide a lot more functionality then the Navision DLLs. I think you will find it a lot easier to use & debug any code that is based on this (as the VS debugging is a billion times better then Navisions).
I think there is also a number of whitepapers on making VB talk to .net to be found on Mibuso and in partnersource.0 -
Oops...that last line was supposed to be: I think there is also a number of whitepapers on making .Net talk to Navision to be found on Mibuso and in partnersource.0
-
Thanks for reply.
I were trying to use the .NET classes, but didn't find anything like 'SendWaitForReply'... maybe I just need to read more about queue handling.
Thanks again0 -
It's been a couple months since I've done anything like this...and I don't have the source code readily available...but basically you need to setup your Message Queue object so that it will receive a response. This is done through setting of properties on either the Message object or the Queue object (or both). You should hunt around MSDN for working with Message Queues. There should be a timeout that you set to wait for the response message...and then if you don't get one an error will occur.
If you are using the MSMQ objects that come with Navision it is very important that you you use the collation ID in your response message (I think there's UseCollationID flag somewhere) and that your message has the correct label ('Navision MSMQ-BA'). The label tells the Navision comcom DLL to pay attention to the message, and the collation ID is used by MSMQ and .Net to match the outbound message with it's corresponding response message.
Check out MSDN, play around with some sample code and googgle should help you get everything working together.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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