SocketBusAdapter, OutStream, buffer size

gensmanngensmann Member Posts: 24
Hello people.

I have a setup with a Webservice querying a NAS via SBA.
It sends an XML document and Navision replies with an XML document based on table data.

When the reply contains more than a couple of table fields, I get the following error message:
"The lenght of the text string exceeds the size of the string buffer"
when OutS.WRITE(XMLDom.xml); is executed in the CC2::MessageRecieved trigger.

If you have any suggestions how I can overcome this problem, they will be highly appreciated. I would like to maintain the AddElement function. Everything works fine when the reply is short. The CC2::MessageRecieved trigger is pasted below:
InMsg := InMessage;
InS := InMsg.GetStream();

XMLDom.load(InS);
XMLNode := XMLDom.selectSingleNode('request');

IF XMLNode.text='CoursePlan' THEN BEGIN
  IF SemRegHdr.FIND('-') THEN BEGIN
    XMLDom.loadXML('<?xml version="1.0" encoding="UTF-8"?><Seminars></Seminars>');
    XMLRoot := XMLDom.documentElement;
    REPEAT
      AddElement(XMLRoot,'SeminarName',SemRegHdr."Seminar Name",'DynUniWeb',ChildNode);
      AddElement(XMLRoot,'StartingDate',FormatDate(SemRegHdr."Starting Date"),'DynUniWeb',ChildNode);
      AddElement(XMLRoot,'Duration',FORMAT(SemRegHdr.Duration),'DynUniWeb',ChildNode);
      AddElement(XMLRoot,'Price','DKK '+FORMAT(SemRegHdr."Seminar Price"),'DynUniWeb',ChildNode);
    UNTIL (SemRegHdr.NEXT = 0);
  END;

END ELSE
  XMLNode.text := 'Request not implemented. Query was: '+ XMLNode.text;

OutMsg := InMsg.CreateReply();
OutS := OutMsg.GetStream();
OutS.WRITE(XMLDom.xml); //Break on error
OutMsg.Send(0);
I hope the variable names are self-explanatory. If not, please ask.

Thanks in advance.
Best regards Poul Anker Gensmann
http://www.gbusiness-solutions.com

Answers

  • gensmanngensmann Member Posts: 24
    Hooray, it works.
    gensmann wrote:
    OutMsg := InMsg.CreateReply();
    OutS := OutMsg.GetStream();
    OutS.WRITE(XMLDom.xml); //Break on error
    OutMsg.Send(0);
    

    I changed this bit to:
    OutMsg := InMsg.CreateReply();
    XMLDom.save(OutMsg.GetStream());
    OutMsg.Send(0);
    

    And all is well (execpt for Danish characters, but I'll look into that.)

    If anyone can explain why this makes it work, it would be nice :)
    Best regards Poul Anker Gensmann
    http://www.gbusiness-solutions.com
  • DenSterDenSter Member Posts: 8,307
    I don't know for sure, but I think it accepts a variant. If the variant is type text, then it has a max size. If the variant is type object then it doesn't. Saving the XMLDOM to the stream directly apparently creates an object.
Sign In or Register to comment.