How to use Flex WebService Component in Flash
时间:2011-05-14 来源:Morris
1.) Prepare done the Flex SDK
2.) Import rpc.swc / Frameworks.swc into Flash
3.) Drag a DataGrid component into stage ( Instance Name : myDG )
4.) Use the following Sample Code
import mx.rpc.soap.*; import mx.core.*; import mx.rpc.events.*; import fl.data.DataProvider; var foo:WebService = new WebService(); foo.addEventListener( "load", loadDone); foo.loadWSDL( "http://www.webservicex.net/country.asmx?WSDL" ); var myOperation:Operation; function loadDone(evt:LoadEvent) { myOperation = Operation( foo.getOperation("GetCountries") ); myOperation.addEventListener( "fault", wsError ); myOperation.addEventListener( "result", wsResult ); myOperation.send(); } function wsError(evt:FaultEvent) { trace(evt); } function wsResult(evt:ResultEvent) { var xml:XML = XML(evt.result); var dp:DataProvider = new DataProvider(xml); myDG.dataProvider = dp; }
相关阅读 更多 +