0 Replies Latest reply on May 11, 2009 3:00 PM by JoshBeall

    How to use AsyncResponder with AsyncToken returned by FB-generated webservice classes?


      Hi All,


      I've got the following code:


                      var service:RosterUpdatesService = new RosterUpdatesService();
                      var token:AsyncToken = service.checkSecurityCode(
                              new Number(usernameTextInput.text),
                              new Number(passwordTextInput.text));


                      token.addResponder(new AsyncResponder(
                          // Result event
                          function (event:Event,context:Object):void{
                              Alert.show("Got a result!");
                          // Fault event
                          function (event:Event,context:Object):void{
                              Alert.show("Got a fault!");
                          ) // End AsyncResponder constructor parameters
                          ); // End addResponder parameters
      //                token.addEventListener(ResultEvent.RESULT,function(re:ResultEvent):void{
      //                    Alert.show("addEventListener works!");
      //                });


      Now, what it's supposed to do is call a web service that I've imported using Flex Builder's web service proxy class code generator (Data->Import Web Service (WSDL)).


      I can see via packet capturing, and monitoring what happens on the server, that the call is being made and that data is returned to Flash player.  However, neigher of my event handlers ever fires.


      I tried using token.addEventListener (as you can see by the commented out code.  If I uncomment that code, I get an alert box that pops up.  However, I can't seem to get the handlers defined by the AsyncResponder to work.


      I've also tried mx.rpc.Responder and mx.collections.ItemResponder (the other two implementations of mx.rpc.IResponder).  No luck with either of those.


      So, why is it that I can get a response using token.addEventListener but not token.addResponder?


      Incidentally, for AMF Flex Remoting services, I've had no trouble with using an IResponder to handle the results...