Call webservice method with parameter in flex 4.5 mobile application

This section contains the declaration of webservice:

<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:WebService
id="getSummaryWeb"
wsdl="http://xyz.com/webservice/serv.cfc?wsdl"
fault="getSummary_faultHandler(event)"
result="getSummary_resultHandler(event)">

<s:operation name="getSummary">
<s:request xmlns="">
<site_id>{p.getProperty('p_sid')}</site_id>
<contact_id>{p.getProperty('p_uid')}</contact_id>
</s:request>
</s:operation>
</s:WebService>
</fx:Declarations>

You can call the above defined web-service at craetionComplete of mxml file using:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Alert Summary"
creationComplete="getSummaryWeb.getSummary.send()">

“getSummary” is the name of method defined in the .cfc page.

Now to get the result of web-service you can use the following code:

public function getSummary_resultHandler(event:ResultEvent):void
{
summaryCollector = event.result as ArrayCollection;
}

Here summaryCollector is a variable of type ArrayCollection.

Leave a Reply

Your email address will not be published. Required fields are marked *