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
Comments
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.
Epimatic Corp.
http://www.epimatic.com
Epimatic Corp.
http://www.epimatic.com
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 again
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.
Epimatic Corp.
http://www.epimatic.com