I'd like to use Function.apply() on WebService instances' web
methods. Should be pretty straightforward, right? Turns out the answer is
no. I figure the quickest way to illustrate my problem is to relate my
journey in a few blocks of code.
Here's a successful sample, using a freebie US ZIP code service.
Note: Make sure to drag a WebServiceClasses compiled clip onto your Stage
from Windows > Common Libraries > Classes.
// FIRST TRY
import mx.services.*;
var wsdl:String = "http://www.webservicex.net/uszip.asmx?WSDL";
var ws:WebService = new WebService(wsdl);
var pc:PendingCall = ws.GetInfoByZIP("90210");
pc.onResult = function(evt) {
trace(evt.NewDataSet);
};
... which traces the following XML ...
<NewDataSet xmlns=""><Table><CITY>Beverly
Hills</CITY><STATE>CA</STATE><ZIP>90210</ZIP><AREA_CODE>310</AREA_CODE><TIME
_ZONE>P</TIME_ZONE></Table></NewDataSet>
Easy.
Now, to transform it into a slightly more generic mechanism ...
// SECOND TRY
import mx.services.*;
var wsdl:String = "http://www.webservicex.net/uszip.asmx?WSDL";
var meth:String = "GetInfoByZIP";
var param:String = "90210";
var ws:WebService = new WebService(wsdl);
var pc:PendingCall = ws[meth](param);
pc.onResult = function(evt) {
trace(evt.NewDataSet);
};
Still successful. Now, Function.apply() takes an array of
arguments, which is the reason I want to use it. To continue stepping in
that direction, I update the above param lines to ...
var param:Array = ["90210"];
... and ...
var pc:PendingCall = ws[meth](param[0]);
... and as expected, all goes well -- still. At this point, I should be
able to slap in Function.apply(), like so ...
// THIRD TRY
import mx.services.*;
var wsdl:String = "http://www.webservicex.net/uszip.asmx?WSDL";
var meth:String = "GetInfoByZIP";
var param:Array = ["90210"];
var ws:WebService = new WebService(wsdl);
var pc:PendingCall = ws[meth].apply(null, param);
pc.onResult = function(evt) {
trace(evt.NewDataSet);
};
... but it all falls apart. If you turn on VERBOSE logging, everything
rolls along as usual until it hangs on the final line ...
3/13 12:7:30 [INFO] : Set active port in service stub: USZip : USZipSoap
Any thoughts?
David
[EMAIL PROTECTED]
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com