PDA

View Full Version : WebService timing problem


Taryel
12-30-2008, 04:38 PM
Hello again there come another bullet

There is some way to wait until a webservice return a full result ???
not embing the source whit the componet but save the result on a local variable and the using it...
There is times that it works but others that an error occurs of "null object reference"

Please help

chadzilla
12-31-2008, 08:19 PM
Use the result attribute of the webservice tag...like this


<mx:WebService id="ws_checkuser" wsdl="http://www.mysite.com/mywebservice.cfc?wsdl">
<mx:operation name="checkuser" resultFormat="e4x" result="myResultFunction(event);">
<mx:request>
<uname>{user.text}</uname>
</mx:request>
</mx:operation>
</mx:WebService>



<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;

private function myResultFunction(event:ResultEvent):void
{
var xmlResult:XML = XML(event.result);
trace(xmlResult.toString());
}

]]>
</mx:Script>


You now have a variable (xmlResult) with your results in it. This example has the webservice return an array of results, but you can easily modify it to return whatever.

Pipan
01-01-2009, 04:12 AM
And howto do if you have used Flex's built in webservice wizard where all needed classes are created for you?

If you want to wait for the full result?