NetTalk Central

Author Topic: manually creating a SOAP response  (Read 3390 times)

JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
manually creating a SOAP response
« on: May 16, 2012, 12:23:54 PM »
I have been building upon the SOAP web server example and am in a situation where I need to build the SOAP response myself rather than using xFIles and data from a queue, which works quite well by the way. In the example application after populating the queue a call is made to:

Xml.Save(StudentResult)

Which seems to populate the reference field xml.xmlData and xml.xmlDatalen

Armed with that little bit of information I used this code to try and put my SOAP response in play:

   xml.xmlData    &= myXmlString[1: LEN(Clip(myXmlString))]
   xml.xmlDataLen = LEN(Clip(myXmlString))

I can see that xml.xmlData does reference my content but after this next line of code is executed I get a Memory Block Free’d Twice error.

    p_web.ParseHTML(Xml.XmlData,1,Xml.XmlDataLen,Net:NoHeader)

Can anyone help me to get around this hurdle?

Thanks

Parker

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: manually creating a SOAP response
« Reply #1 on: May 16, 2012, 09:10:32 PM »
Hi Parker,

If you don't want to use the xFiles string, then don't use it. You have a couple simple options;

str   string(16000)

  code
  str = whatever
  p_web.ParseHTML(str,1,len(clip(str)),Net:NoHeader)

This is fine if you're pretty sure the string will be less than the size you declared. (you can make the declaration bigger if you like).

Indeed in your code;
    p_web.ParseHTML(myXmlString,1,LenClip(myXmlString)),Net:NoHeader)


If you must have a dynamic length string then perhaps use StringTheory;

str   StringTheory
  code
  str.SetValue(whatever)
  p_web.ParseHTML(str.GetValue(),1,str.Length(),Net:NoHeader)

The reason it gives the error BTW is because you've not cleared xml.xmlData after using it. ie

  xml.xmlData &= NULL

after the ParseHTML will probably do the trick.

cheers
Bruce




JPMacDonald

  • Full Member
  • ***
  • Posts: 106
    • View Profile
    • Email
Re: manually creating a SOAP response
« Reply #2 on: May 17, 2012, 03:56:06 AM »
Hey Bruce,

I like xFiles just fine, in fact it is used for 90% of the SOAP responses in this particular application. The one odd-ball is a complicated (for me anyway) nested structure that I needed to return but I don't have enough grey cells to make it work with xFiles.

This statement on its own still causes the Memory Block Free'd Twice error:

p_web.ParseHTML(myXmlString,1,LEN(Clip(myXmlString)),Net:NoHeader)

but putting the xml.xmlData &= NULL after the ParseHtml works just fine.

Thanks for the help and ideas, much appreciated as always.

Regards

Parker