View Full Version : web service parameters
johnagrandy
05-10-2003, 06:09 PM
when requesting data from a web service i am not having luck using setQueryString ...
i am wondering if i can specify the parameters directly in the src url:
<dataset name="dataXignite"
src="http://www.xignite.com/xquotes.asmx/GetQuotesHistorical?Symbol='MSFT'&Month=12&Year=2002"
type="http" autorequest="false" />
but this gives the compile error:
Error: securities2.lzx:4:92: The reference to entity "Month" must end with the ';' delimiter.
antun
05-10-2003, 07:42 PM
Have you tried URL encoding the apostrophes (single-quotes around MSFT)? I belive it would be %27:
<dataset name="dataXignite"
src="http://www.xignite.com/xquotes.asmx/GetQuotesHistorical?Symbol=%27MSFT%27&Month=12&Year=2002"
type="http" autorequest="false" />
-Antun
antun
05-10-2003, 07:55 PM
Do you want to post your code so we can debug it?
when requesting data from a web service i am not having luck using setQueryString ...
johnagrandy
05-10-2003, 09:40 PM
well, the single quotes actually aren't needed ...
however, removing them still gives the same error:
<dataset name="dataXignite"
src="http://www.xignite.com/xquotes.asmx/GetQuotesHistorical?Symbol=MSFT&Month=12&Year=2002"
type="http" autorequest="false" />
Error: securities2.lzx:4:88: The reference to entity "Month" must end with the ';' delimiter.
antun
05-10-2003, 10:32 PM
Hey johnagrandy
Sorry to send you on a wild goose chase. This appears to be a very strange compiler bug. I'm going to look into it more, but in the meantime, here is how to actually set the querystring using the setQueryString() method, and spit the returned XML out in the debugger (I understand this is what you were trying to do originally):
<canvas debug="true">
<dataset name="dataXignite"
src="http://www.xignite.com/xquotes.asmx/GetQuotesHistorical"
type="http" autorequest="false" />
<view name="test" datapath="dataXignite:/"
ondata="debug.write( this.datapath.serialize() )">
</view>
<button>
<method event="onclick">
var ds = canvas.datasets.dataXignite;
ds.setQueryString( {Symbol : 'MSFT', Month : '12', Year : '2002'} );
ds.doRequest();
</method>
</button>
</canvas>
Take care,
Antun
johnagrandy
05-11-2003, 08:27 AM
ahhh .... only one SetQueryString() function is used ... that is the trick ...
as far as the characters in the src parameter which the compiler does not like, i think this is completely due to xml's allowable character set. if you make substitutions with the appropriate entity references, then it works
antun
05-11-2003, 09:15 AM
I think you're right here. If you write:
&Month
... then the compiler thinks it's going to be an XML special character (like > etc.), so it complains. If you substituted the ampersand with &amp;, like you suggested that should work.
Also remember that in a <method>, you can use CDATA tags to escape the whole node.
-Antun
... i think this is completely due to xml's allowable character set. if you make substitutions with the appropriate entity references, then it works
johnagrandy
05-12-2003, 09:12 AM
Antun, do you know how to accumulate multiple web-service requests-for-data into a lzDataset?
another way to ask the question: how to append one lzDataset onto another?
antun
05-12-2003, 09:15 AM
Are you sure that's what you want to do? It's perfectly normal to have multiple datasets in an app, you know.
-Antun
how to append one lzDataset onto another?
johnagrandy
05-12-2003, 09:35 AM
hmmm ... well, at this point i am just experimenting with different options
ok, this web-service only provides data in chunks ...
it would seem to be most convenient to aggregate those chunks together into a single dataset ...
but perhaps i can store multiple datasets in an array, or other structure?
what is clear to me is that i need to retrieve multiple chunks before doing any display
antun
05-12-2003, 10:14 AM
All of the datasets are available globally as follows:
<canvas>
<dataset name="myFirstDS" />
<dataset name="mySecondDS" />
<script>
var ds = canvas.datasets.myFirstDS;
var dsTwo = canvas.datasets.mySecondDS;
</script>
</canvas>
Now, if you did want to aggregate data, you would use the datapointer's addNodeFromPointer() method:
http://www.laszlosystems.com/developers/learn/documentation/lzxref/datapointer.php#meth-addNodeFromPointer
You would have two datapointers - point one at a (blank?) dataset where you want to add the node, and point the other to a place where you want to copy from.
-Antun
But perhaps i can store multiple datasets in an array, or other structure?
antun
05-15-2003, 02:55 PM
BTW, copying nodes inspired me to write this weeks tip:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=222
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.