Error writing a xml content with MSMQ

jcruzjcruz Member Posts: 3
edited 2006-10-27 in Navision Attain
Hi everyone,
I'm trying to send a xml file content to a MSMQ that will be read by a C# application. The NAV code set a Item record filter by "Service Item Group" and than use u XMLPort to get the data generated. For now, i've simplified the code just to print the xml content, and i'm getting this error: The length of the text string exceeds the size of the string buffer when i try to print it (MESSAGE), and the same ocurrs when i try to send the content to a MSMQ :(

Here's the code:

CREATE(XMLDom);

Item.SETFILTER ("Service Item Group",'ACESSDIV');

TestFile.CREATE('C:\XML_Item.xml');
TestFile.CREATEOUTSTREAM(TestStream);
XMLPORT.EXPORT(123456701,TestStream,Item); //Use any codeunit for test porpose folks...
TestFile.CLOSE;

XMLDom.load('C:\XML_Item.xml');

MESSAGE(XMLDom.xml); // *** HERE'S OCCUR THE ERROR ***

CLEAR(XMLDom);CLEAR(Item);


Automation Variables:
XMLDom Automation 'Microsoft XML, v6.0'.DOMDocument
Item Record Item
TestFile File
TestStream OutStream


Can anyone solve this error? :(
Nunca discutas com um idiota em público...podem não distinguir quem é quem...

Comments

  • nunomaianunomaia Member Posts: 1,153
    IF the XMLDom.xml is larger than 1024 you will have problems.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • RoelofRoelof Member Posts: 377
    What about importing XML files bigger then 1024 characters? Does that give a problem too?
    Roelof de Jonghttp://www.wye.com
  • nunomaianunomaia Member Posts: 1,153
    Navision imports without any problems large XML files.

    The problem happens if you try to store a string value lager than the specific string value.
    For example if you try to save a customer name larger than 30 chars and Navision by default only stores 30 chars
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • RoelofRoelof Member Posts: 377
    Then I have another question. I try to import an XML SalesOrder with multiple SalesLines in a DOM. I can read the SalesHeader and the first SalesLine. But how can I read the next SalesLine in a DOM.
    Roelof de Jonghttp://www.wye.com
  • nunomaianunomaia Member Posts: 1,153
    Are you reading using a dataport or using Automation?
    If you are using automation can you show me a sample of you code?
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • RoelofRoelof Member Posts: 377
    I am using an automation.
    Here is a piece of my code. The loop basically starts at the 'WHILE DO' line. I copied this more or less from a standard Navision function in CodeUnit 6226, function 'Sales'.

    WITH XMLDOMManagement DO BEGIN
    XMLNode := XMLDocIn.documentElement;
    DataLineArea := '/po:ProcessPurchaseOrder/po:DataArea/po:PurchaseOrder/po:Line/po:';

    IF FindNodes(XMLNode,DataLineArea+'Line',XMLNodeList) THEN BEGIN //to find PO-Line node
    //XMLNodeList.reset();
    //XMLNode:= XMLNodeList.nextNode();
    WHILE NOT ISCLEAR(XMLNode) DO BEGIN //not looping. Need to fix that.
    IF FindNode(XMLNode,DataLineArea+'OrderItem/po:Description',XMLNodeFound) THEN
    IF STRLEN(XMLNodeFound.text) > 0 THEN
    EVALUATE(SheetLine.Description,XMLNodeFound.text);
    .
    .
    .
    XMLNode:= XMLNodeList.nextNode();
    END;
    END;
    END;

    The code is working but only for the first SalesLine Node. The next SalesLineNode is not being read.
    Roelof de Jonghttp://www.wye.com
  • nunomaianunomaia Member Posts: 1,153
    In that codeunit you have code to iterate nodes
    ...
      IF FindNode(XMLRootNode,'ROLES',XMLNodeFound) THEN BEGIN
        IF NOT FindNodes(XMLNodeFound,'ROLENO',XMLNodeList) THEN
          EXIT
        ELSE
          FOR I := 0 TO XMLNodeList.length - 1 DO BEGIN
            TempWebPortalUserRoles."Web Portal Role Code" := XMLNodeList.item(I).text;
            IF NOT TempWebPortalUserRoles.INSERT THEN;
          END
      END ELSE
    ...
    
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • DenSterDenSter Member Posts: 8,304
    It's the MESSAGE that kills it. The XMLDOM is perfectly capable of holding more than 1024 characters, because that's not a string but an object in memory. It's when you try to access the entire string of the variable when NAV chokes.
  • RoelofRoelof Member Posts: 377
    Nunomaia,

    Is this the solution for my salesline next read problem in a DOM? I'm confused.
    If so, can you explain how it works?
    Roelof de Jonghttp://www.wye.com
  • nunomaianunomaia Member Posts: 1,153
    FindNode returns a simles Node (First Line)

    FindNodes return all the lines.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • RoelofRoelof Member Posts: 377
    I tried this option but it failed.
    It looks like I have a problem with the XMLNodeList. For some reason it doesn't return an node list although it finds the first salesLine node in the XML file.
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.