4 Replies Latest reply on Nov 5, 2009 12:27 PM by paul.williams

    HTTPService result handler fires twice when called using AsyncToken

    shekel2000 Level 1

      HTTPService is defined as:
      <mx:HTTPService id="recurrenceHttpService" url="http://localhost:8080/project/recurrence.ajax"
              method="GET" resultFormat="xml" useProxy="false" showBusyCursor="true"/>

       

      when i call an http service using:
      service.addEventListener(ResultEvent.RESULT, responder.result);
      service.addEventListener(FaultEvent.FAULT, responder.fault);
      service.send(params);

      (responder is an IResponer, params is an object with the parameters)

      The result is correct one call to the result handler.

       

      but when i call it using an AsyncToken:
      var token:AsyncToken = service.send(params);
      token.addResponder(responder);

       

      the result handler is called twice.

       

      This is the stack in both cases.
      first time:   
          com.structures.commands::GenerateDatesForRecurrenceCommand/result   
          mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult   
          mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders   
          HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent   
          mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler   
          mx.rpc::Responder/result   
          mx.rpc::AsyncRequest/acknowledge   
          DirectHTTPMessageResponder/completeHandler   
          flash.events::EventDispatcher/dispatchEventFunction [no source]   
          flash.events::EventDispatcher/dispatchEvent [no source]   
          flash.net::URLLoader/onComplete [no source]   
      Second Time:
          com.structures.commands::GenerateDatesForRecurrenceCommand/result   
          mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult   
          mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders   
          mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent   
          HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent   
          mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler   
          mx.rpc::Responder/result   
          mx.rpc::AsyncRequest/acknowledge   
          DirectHTTPMessageResponder/completeHandler   
          flash.events::EventDispatcher/dispatchEventFunction [no source]   
          flash.events::EventDispatcher/dispatchEvent [no source]   
         
      ideas?