Error while sending an XML document from Navision to MSMQ

subhaster
subhaster Member Posts: 64
Hi Everyone !
I am getting a strange error , when I am trying to send a XML document from Navision to MSMQ. here is my code :-

CLEAR(CC2);
CLEAR(MqBUS);
CREATE(CC2);
CREATE(MqBUS);
CC2.AddBusAdapter(MqBUS,1);
MqBUS.OpenWriteQueue('.\Private$\fromnavision',0,0);
OutMsg := CC2.CreateoutMessage('Message queue://');

IF ISCLEAR(XmlDom) THEN
 CREATE(XmlDom);
XMLDOMManagement.SetNormalCase;
XMLProccesingInst := XmlDom.createProcessingInstruction('xml','version=''1.0'' encoding=''utf-8''');
XMLCurrNode := XmlDom.appendChild(XMLProccesingInst);



CLEAR(XMLCurrNode);
XMLCurrNode := XmlDom.createElement('ResponseXml');
XmlDom.appendChild(XMLCurrNode);


IF vEntity='SellToCustomerNo' THEN
BEGIN
Customer.FIND('-');
REPEAT
XMLCurrNode2 := XMLCurrNode.ownerDocument.createNode('element', 'Entity', '');
XMLCurrNode2.text:='SellToCustomerNo';
XMLCurrNode.appendChild(XMLCurrNode2);

IF XMLDOMManagement.AddElement(XMLCurrNode,'Values','','',XMLCurrNode)>0 THEN EXIT;

 ParentNode := XmlDom.createElement('Value');
 XMLCurrNode.appendChild(ParentNode);
 Node := XmlDom.createElement('Code');
 Node.text:=Customer."No.";
 ParentNode.appendChild(Node);
 Node := XmlDom.createElement('Description');
 Node.text:=Customer.Name;
 ParentNode.appendChild(Node);

UNTIL Customer.NEXT=0;
END;

OutS := OutMsg.GetStream();
OutS.WRITE(XmlDom.xml);
OutMsg.Send(0);


And the error message that I am getting is :-
Length of the text string exceeds the size of the string buffer

Can anyone please suggest me a solution ?
Thanks in advance.
Subhasish Chakraborty,
Systems Analyst,
MBS Dynamics.

Comments

  • ara3n
    ara3n Member Posts: 9,258
    turn on the debugger and see where it stops. My guess you are passing a string that is longer then 250 characters.
    I suggest using xmlports
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • subhaster
    subhaster Member Posts: 64
    Hi Rashed !
    I cannot turn the debugger on as I am using the NAS to detect the output. Also the project where I am using this code , is using only XML Doms , not XML Ports.
    What I am tying to is to fill up a combo box in a front end (designed in .net), which on getting loaded is generating an Xml file hthat is detected by the NAS . This XML contains informations regarding a request to Navision to supply all the customers in an XML format . The codeunit which I have designed is doing this.....it is generating an XML file forwarded to MSMQ, which is going to picked up by a web service, which parses the XML to decode the customfer nos and fill up the comobo box. But I am getting the error the moment I am sending the XML Document to MSMQ. The XML document is really a very big one, as it contains a huge list of customers .
    Can you suggest me , how can O come around this problem.
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • subhaster
    subhaster Member Posts: 64
    Hi Rashed !
    I cannot turn the debugger on as I am using the NAS to detect the output. Also the project where I am using this code , is using only XML Doms , not XML Ports.
    What I am tying to is to fill up a combo box in a front end (designed in .net), which on getting loaded is generating an Xml file hthat is detected by the NAS . This XML contains informations regarding a request to Navision to supply all the customers in an XML format . The codeunit which I have designed is doing this.....it is generating an XML file forwarded to MSMQ, which is going to picked up by a web service, which parses the XML to decode the customer nos and fill up the combo box. But I am getting the error the moment I am sending the XML Document to MSMQ. The XML document is really a very big one, as it contains a huge list of customers .
    Can you suggest me , how can I come around this problem ?
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • ara3n
    ara3n Member Posts: 9,258
    OutS := OutMsg.GetStream();

    //Your issue is line bellow.
    OutS.WRITE(XmlDom.xml);

    you need to changeit.


    XmlDom.save(OutS);



    OutMsg.Send(0);
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • subhaster
    subhaster Member Posts: 64
    Hi Rashed ,
    thanks a lot........ it worked !!! \:D/
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • ara3n
    ara3n Member Posts: 9,258
    you are welcome.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • subhaster
    subhaster Member Posts: 64
    Rashed,
    it worked , but still it is giving a strange error..... in MSMQ I am getting only a pert of it . Say for example, if there are 90 customers in my customer table, in MSMQ I am getting a XML of only 6 customers out of it ! Can you suugest me , how can I come around this ?
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • ara3n
    ara3n Member Posts: 9,258
    hmm
    I don't know enough about message queue to know the exact cause. This must be a memory setup limit somewhere. try to google it.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • frede
    frede Member Posts: 80
    Thx to ara3n - you just saved my day (and evening...)
    Regards,

    Henrik Frederiksen, Denmark
  • ara3n
    ara3n Member Posts: 9,258
    You are welcome. As far as partial xml file make sure you add xmldom.async := false
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • frede
    frede Member Posts: 80
    Hmmm..ok?

    How about changing the codepage - is that possible (from UTF-8 to UTF-16 for instance)?
    Regards,

    Henrik Frederiksen, Denmark
  • ara3n
    ara3n Member Posts: 9,258
    frede wrote:
    Hmmm..ok?

    How about changing the codepage - is that possible (from UTF-8 to UTF-16 for instance)?

    You are referring to Encoding not codepage. Yes it's possible to change the codepage, asumming the xml file is in that encoding.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • frede
    frede Member Posts: 80
    Pardon my french...

    ...Yes, I was talking about the encoding (XML is new to me(!))....

    How can I easily do this...I am trying to use a "aEncConv"-program from

    http://dynamicsuser.net/blogs/nunomaia/ ... ter-2.aspx

    Don't know if there is an easier way than to start saving files to disc and then load again...?

    Thx in advance for your time...
    Regards,

    Henrik Frederiksen, Denmark