0 Replies Latest reply on May 12, 2009 2:27 PM by JoshBeall

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

    JoshBeall Level 1

      Hi All,

       

      I posted this in Flex Data Services, but that might be the wrong forum--not sure if Flex Data Services refers to some particular Flex thing, like BlazeDS or a similar product.  I'm just using a generic SOAP web service.

       

      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!");
                              return;
                          },
                          // Fault event
                          function (event:Event,context:Object):void{
                              Alert.show("Got a fault!");
                              return;
                          },
                          this
                          ) // End AsyncResponder constructor parameters
                          ); // End addResponder parameters
                         
      //                token.addEventListener(ResultEvent.RESULT,function(re:ResultEvent):void{
      //               
      //                    Alert.show("addEventListener works!");
      //               
      //                });
                      Alert.show("Sending!");

       

      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...

       

        -Josh