I have been struggling with the "Element not resolvable" error today
in some of my unit tests using FlexUnit. As far as I can tell, the
LoadEvent doesn't imply that the service is ready. If I put a timer
in and wait 1 second after the load event to make my service call,
everything works correctly. If I don't wait 1 second, however, then
I receive the "Element not resolvable" error. This appears to be a
bug in the WebService class.
Here's my sample code:
import mx.rpc.soap.WebService;
import flash.events.Event;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.LoadEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class SoapDemoTest {
public function testListVocabularies():void {
trace('testListVocabularies');
ws = new mx.rpc.soap.WebService();
ws.addEventListener(LoadEvent.LOAD, onLoadCompleted);
ws.loadWSDL("http://192.168.1.1:8080/myserv/myserv?wsdl");
}
private function onLoadCompleted(evt:LoadEvent):void {
trace('onLoadCompleted');
// if I just call ws.listVocabularies, I receive the
// Cannot Resolve Element error.
ws.addEventListener(ResultEvent.RESULT,onResultReceived);
ws.listVocabularies(5,true);
/*
// if I use this timer instead of the above, everything works
var timer:Timer = new Timer(1000, 1);
timer.addEventListener(
TimerEvent.TIMER_COMPLETE,
onTimerComplete
);
timer.start();
*/
}
private function onTimerComplete(evt:TimerEvent):void {
trace("onTimerComplete");
ws.addEventListener(ResultEvent.RESULT,onResultReceived);
ws.listVocabularies(5,true);
}
private function onResultReceived(evt:ResultEvent):void {
trace("onResultReceived");
trace("result: " + evt.result.toString());
}
}
To test, simply fire testListVocabularies() in a CreationComplete
event handler.
Can anyone else confirm this? By the messages, it sounds like the
exact same thing that a number of people are running into.
Thanks for the help.
--Kaleb
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/