View Full Version : Auto-parsing strings ?...
i'm trying to build a class to handle SOAP webservices, and i've discovered something strange while trying to do so...
in a dataset i get a response with a SOAP Envelope, like:
<soapenv:Envelope...><soapenv:Body>.....<result>Myresult</result>...</soapenv:Body></soapenv:Envelope>
i serialize a datapointer pointing to this dataset:
var mystring = pointer.serialize();
then i print 'mystring' in the Debug window and i get this:
<Envelope><Body>......</Envelope>
without the namespaces and the attributes
but the most amazing is when i put 'mystring' in a text component which eventually displays:
<result>Myresult</result>
hence my question: does Laszlo try to parse strings in a certain way before displaying them euther in the debug window or in other text displayers?
i tried with an other service and got this strange '<<string0#' tag in the debug window right before my string...
any clue about this strange issue ?
antun
05-06-2004, 12:48 PM
Can you post some of the raw (pre-Laszlo) XML that your class is returning, so that I can give it a try?
-Antun
### Message sent by the webservice:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getDataResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getDataReturn xsi:type="xsd:string"><A><B><D><DD>textDD1</DD><DD>textDD2</DD></D></B></A></getDataReturn>
</getDataResponse>
</soapenv:Body>
</soapenv:Envelope>
### String printed in the debug window
<Envelope><Body><getDataResponse encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><getDataReturn type="xsd:string"><A><B><D><DD>textDD1</DD><DD>textDD2</DD></D></B></A></getDataReturn></getDataResponse></Body></Envelope>
### String displayed in the text component
<A><B><D><DD>textDD1</DD><DD>textDD2</DD></D></B></A>
antun
05-06-2004, 04:46 PM
I've discovered that namespaces aren't supported in LPS 2.x. Although datapaths will work, the namespaces will get stripped out, so you won't see them or get their special functionality.
Now if you serialize a datapointer, you'll be assigning the special characters < and > to the string, so if you print it to a text they won't appear. When I tried the following example:
<canvas debug="true" width="800">
<debug x="400" />
<dataset name="myds">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getDataResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getDataReturn xsi:type="xsd:string"><A><B><D><DD>textDD1</DD><DD>textDD2</DD></D></B></A></getDataReturn>
</getDataResponse>
</soapenv:Body>
</soapenv:Envelope>
</dataset>
<simplelayout axis="y" spacing="10" />
<text datapath="myds:/Envelope/Body/getDataResponse/@encodingStyle"
width="300" />
<datapointer name="mydp" xpath="myds:/Envelope/Body/getDataResponse" />
<button>Serialize
<method event="onclick">
Debug.write( mydp.serialize() );
</method>
</button>
</canvas>
... I got nothing in the text field. You might be able to write a method that escapes the < and > to &lt; and &gt; respectively.
The debugger does this automatically with strings.
-Antun
ok, i begin to understand what happens...
the last thing i don't catch yet is why when i do: var toto = thePointer.serialize();
canvas.myText.setText(toto);
it turns out to display the following string:
<A><B><D><DD>textDD1</DD><DD>textDD2</DD></D></B></A>
although it contains the special characters < and >...
antun
05-07-2004, 08:11 AM
I'm not seeing that at all. If you run the code I posted, does it write anything to the yellow text field?
-Antun
Originally posted by 3.14
ok, i begin to understand what happens...
the last thing i don't catch yet is why when i do: var toto = thePointer.serialize();
canvas.myText.setText(toto);
it turns out to display the following string:
<A><B><D><DD>textDD1</DD><DD>textDD2</DD></D></B></A>
although it contains the special characters < and >...
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.