|
Once the class 'WebService' has been istantiated and the WSDL document describing the web service operations has been loaded, trough the 'WebService' object it is possible to call the methods corresponding to the web service operations.
Consider 'idWebService' as the identifier of the 'WebService' instance and that in the WSDL document is defined an operation like this:
<wsdl:operation name="getNamesArray"> <wsdlsoap:operation soapAction="" /> <wsdl:input name="getNamesArrayRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services" use="encoded" /> </wsdl:input> <wsdl:output name="getNamesArrayResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://lucabonacorsi.org/exampleWebService" use="encoded" /> </wsdl:output> </wsdl:operation>
then the ActionScript code to use is 'idWebService.getNamesArray();'.
For example, if we wanted to call such a method soon after the WSDL document has been loaded, we could exploit the 'load' event of the 'WebService' class this way:
<mx:WebService id="idWebService" wsdl="http://lucabonacorsi.org/exampleWebService?wsdl" load="idWebService.getNamesArray();" />
If we were interested in calling that method in response to a button 'click', we could take advantage of the following MXML code:
<mx:Button label="get all names" click="idWebService.getNamesArray();" />
The 'getNamesArray' operation, set here as an example, is supposed to return a data 'array'. This data structure in Flex/ActionScript is represented trough an 'ArrayCollection' object.
We will focus on this aspect in another article.
|