Message Queues with Navision

ajaybabuCh
Member Posts: 208
Hi
I have seen one example in MSDN regarding Navision Communication through Message Queues. which passes a string to navision and gets back the string with uppercase from an windows application through Message Queues.
for reference :
Talking with Navision: Say Hello to Navision and Expect Navision to Be Polite
http://msdn2.microsoft.com/en-us/library/ms952182.aspx
If I pass Dataset as follows to the Mesage Queue :
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
sqlconn.ConnectionString = "database=VConnect;server= (local);user id=sa;password=password2006"
Dim rs As New DataSet
Dim da As SqlDataAdapter
Dim Command As New SqlCommand
Command.CommandType = CommandType.Text
Command.CommandText = "SELECT * FROM VK_Suppliers"
sqlconn.Open()
Command.Connection = sqlconn
da = New SqlDataAdapter(Command)
da.Fill(rs)
mqToNavision.Send(rs.Tables(0), "Navision MSMQ-BA")
mqFromNavision.BeginReceive(New System.TimeSpan(0, 0, 0, 30))
sqlconn.Close()
End Sub
What code I need to write in the following Automation Event to receive that dataset.
CC2 automation 'Navision Communication Component version
2'.CommunicationComponent
CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
regards
ajay
I have seen one example in MSDN regarding Navision Communication through Message Queues. which passes a string to navision and gets back the string with uppercase from an windows application through Message Queues.
for reference :
Talking with Navision: Say Hello to Navision and Expect Navision to Be Polite
http://msdn2.microsoft.com/en-us/library/ms952182.aspx
If I pass Dataset as follows to the Mesage Queue :
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
sqlconn.ConnectionString = "database=VConnect;server= (local);user id=sa;password=password2006"
Dim rs As New DataSet
Dim da As SqlDataAdapter
Dim Command As New SqlCommand
Command.CommandType = CommandType.Text
Command.CommandText = "SELECT * FROM VK_Suppliers"
sqlconn.Open()
Command.Connection = sqlconn
da = New SqlDataAdapter(Command)
da.Fill(rs)
mqToNavision.Send(rs.Tables(0), "Navision MSMQ-BA")
mqFromNavision.BeginReceive(New System.TimeSpan(0, 0, 0, 30))
sqlconn.Close()
End Sub
What code I need to write in the following Automation Event to receive that dataset.
CC2 automation 'Navision Communication Component version
2'.CommunicationComponent
CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
regards
ajay
Ajay
0
Comments
-
Hi there....
I already did that!
I think you can get help here:
http://msdn.microsoft.com/library/defau ... ayerws.asp
Regards,Miguel Carvalho0 -
the example using webservices in MSDN talking about sending a record from navision to outside application. Out side application is sending the item number through message queue and navision parse the request and fetch the corresponding item record and frame that record in xml and send it back to outside application. its fine.
but my scenario is I have a set of records , how to send these set of records to Navision through Message queues.
For example I have a table Temp contains 100 records in sql db. from the
outside application(assume that this is windows application using vb .net or C#). how can i send these 100 records to the message queue at a time
if i were send those set of records to message queue , what code i have to write in navision to receive these set of records.
regards
ajayAjay0 -
can anybody give an idea on thisAjay0
-
need more stuff on this , plzAjay0
-
ajay -
why pass the entire dataset? Why not use dataset.WriteXML to write the data as XML to the Message Queue?0 -
Since your using XML, why not use XML to receive your records?
Storing them as an XML Document and read that using the DOM?
From the devguide.chm on the Navision install Disk
Receiving a Document - Code Example 2
In this example, we use a single instance codeunit to initialize the Navision Communication Component, establish contact to a Navision MS-Message Queue Bus Adapter, open the bus adapter's receive queue, read the message that is received and then send a reply.
For the purpose of this example, we have defined the following variables:
Variable Name Data Type Subtype Length
MQBus Automation 'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter
CC2 Automation 'Navision Communication Component Version 2'.CommunicationComponent
InMsg Automation 'Navision Communication Component version 2'.InMessage
InS InStream
Txt Text 100
OutMsg Automation 'Navision Communication Component version 2'.OutMessage
OutS OutStream
Note that in the following example, you can use .\MyQueue (instead of MyMessageQueueServer\MyQueue) if you have installed the Microsoft Message Queue Server on your local machine.
ExampleOnRun() CREATE(MQBus); CREATE(CC2); MQBus.OpenReceiveQueue('MyMessageQueueServer\comcom2_queue',0,0); CC2.AddBusAdapter(MQBus,1); CC2::MessageReceived(VAR InMessage : Automation) InMsg:= InMessage; IF (InMsg.ExpectReply) THEN BEGIN InS:= InMsg.GetStream(); InS.READ(Txt); MESSAGE(Txt); OutMsg:= InMsg.CreateReply(); OutS:= OutMsg.GetStream(); OutS.WRITE('Yes, hello world! OK.'); OutMsg.Send(0); END; InMsg.CommitMessage();
0 -
Hi the above example , I did that one
But if .Net application sends a set of records to the message queue in an xml format , how can i receive those set of records in navision single instance codeunitAjay0 -
What do you mean Single instance codeunit?
That should have nothing to do with it, if you Message payload is an XML document. You Store the XML in a temp file or steam it inside Navision.
Whats the exact problem? Have you coded it and get an error? If so whats the error? Or are you still designing it?
/TH0 -
Agreed - the Message Queue should contain the message - which should consist of the XML document that was serialized by your .Net app...
In Navision, you should only have to iterate the nodes using the XML DOM objects.0 -
hi thanq fisherman. thats what exactly i want, u got my point.
can u send some code example for thisAjay0 -
Hi Tony
The example that u have given, just talking about a simple string.
you are receiving a string from .net and u r sending the string back
to .net using MSMQ.
If I receive set of records in XML format through message queue how to
parse them in Navision. I need a simple example.
ajayAjay0 -
You'll need to use the XMLNode.SelectSingleNode() method.
the XMLNode object is a member of the Microsoft XMLDOM libraries, and allows you to iterate the nodes of an XML document. Note that I'm saying nodes here, and not elements - in XML, both elements AND attributes are considered nodes.
SelectSingleNode accepts a parameter in the form of an XSL/XPath query.
For an example of how to use SelectSingleNode, look here
For an example of how to access Navision through a web service, look here
finally - for information on XSL and XPath queries, check out w3school under the XML tutorials.0 -
thanq fisherman.
Is it really feasible to develop third party application using message queues.
I am with lot of problems while developing the integration with MessageQueues.
all the messages struk up in the queue and only, navision picks up the first message.
do u know how to clear the messages in the queue
ajayAjay0 -
Do you want to paste your code or PM me it?
I've done this 3 times. Twice with MSMQ and once with MQSeries so I know it works :-)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