Message Queues with Navision

ajaybabuChajaybabuCh 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
Ajay

Comments

  • ZMikeZMike Member Posts: 10
    Hi there....
    I already did that! :D

    I think you can get help here:
    http://msdn.microsoft.com/library/defau ... ayerws.asp

    Regards,
    Miguel Carvalho
  • ajaybabuChajaybabuCh Member Posts: 208
    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
    ajay
    Ajay
  • ajaybabuChajaybabuCh Member Posts: 208
    can anybody give an idea on this
    Ajay
  • ajaybabuChajaybabuCh Member Posts: 208
    need more stuff on this , plz
    Ajay
  • FishermanFisherman Member Posts: 456
    ajay -

    why pass the entire dataset? Why not use dataset.WriteXML to write the data as XML to the Message Queue?
  • TonyHTonyH Member Posts: 223
    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.

    Example
    OnRun()
    
    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();
    
  • ajaybabuChajaybabuCh Member Posts: 208
    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 codeunit
    Ajay
  • TonyHTonyH Member Posts: 223
    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?

    /TH
  • FishermanFisherman Member Posts: 456
    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.
  • ajaybabuChajaybabuCh Member Posts: 208
    hi thanq fisherman. thats what exactly i want, u got my point.

    can u send some code example for this
    Ajay
  • ajaybabuChajaybabuCh Member Posts: 208
    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.

    ajay
    Ajay
  • FishermanFisherman Member Posts: 456
    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.
  • ajaybabuChajaybabuCh Member Posts: 208
    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

    ajay
    Ajay
  • TonyHTonyH Member Posts: 223
    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 :-)
Sign In or Register to comment.