views:

308

answers:

1

How does one change / modify the Result property of a web service operation?

For example, I have declared my WebService as follows:

<mx:WebService id="ws">
  <mx:operation name="Call_One" result="Call_OneRH(event)" fault="Call_OneFH(event)" />
  <mx:operation name="Call_Two" result="Call_TwoRH(event)" fault="Call_TwoFH(event)" />
</mx:WebService>

I want to be able to change the result of the operation "Call_One" to another result, since I am planning to re-use the same web service, but the result would be treated differently.

Am not sure if this would work:

ws.operation.Call_One.result = "myOtherResult"

Inputs highly appreciated. Thanks.

+1  A: 

don't add a handler into the operation directly, but add a listener to the webservice to handle the result. Documentation states that the result event is dispatched if it isn't handled by the Webservice itself.

public function addListeners() : void {
    ws.addEventListener( ResultEvent.RESULT, Call_OneRH );
}

public function changeListener() : void {
    ws.removeEventListener( ResultEvent.RESULT, Call_OneRH );
    ws.addEventListener( ResultEvent.RESULT, myOtherResult );

<mx:WebService id="ws">
    <mx:operation name="Call_One" fault="Call_OneFH(event)" />
    <mx:operation name="Call_Two" result="Call_TwoRH(event)" fault="Call_TwoFH(event)" />
</mx:WebService>
Gregor Kiddie