XMLPort.IMPORT and MSMQ

salkiensalkien Member Posts: 2
Hello!

I am trying to integrate Navision with .NET through XMLPort funcionality and I cannot make XMLPort.IMPORT working. I have the code which successfully receives a message from the MSMQ, but I cannot pipe it to the XMLPort.
CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
// get the xml  message
InMsg := InMessage;
InS := InMsg.GetStream();
// import xml into Navision
XMLPort.IMPORT(50010, InS);
I got the XMLParser error. I tried to save the InS to file to see what went wrong, but it went on and on, duplicating the original message in infinite loop. Can anyone help me how to use XMLPort.IMPORT with the XML message from the MSMQ?

Comments

  • DenSterDenSter Member Posts: 8,307
    You are missing a few steps, this should do the trick:
    CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
    // get the xml  message
    InMsg := InMessage;
    InS := InMsg.GetStream();
    
    // Your XMLPort should be a variable
    MyXMLPort.SETSOURCE(instr);
    
    // import xml into Navision
    IF MyXMLPort.IMPORT THEN
      MESSAGE('everything ok')
    ELSE
      MESSAGE('found an error');
    

    Note that XMLPorts cannot update records, only import new ones. You have to program your XMLPort to handle that separately. Make sure that the records in your sample file are all new records.

    Check out codeunit 99008518 for more examples of how Commerce Gateway uses XMLPorts.
Sign In or Register to comment.