Skip navigation
bencoderedit
Currently Being Moderated

WebService response delay once loaded

Aug 5, 2010 4:27 AM

I have a flex 4 app consuming some services using the code generation tool in Flash Builder.

 

One of the services returns a fairly large result (500kb ish) If I use firebug I can see the download finishing after a couple of seconds. But then the flex app hangs for a number of seconds once the result has been received.

I presume this is a delay in casting the result to the generated type.

This delay is horribly ugly in my app as it can happen while video is playing, causing the video to stall but the audio to continue playing.

 

Is there any way to either speed up this delay or allow it to run as normal user code does allowing other visual operations to continue?

 

If there isn't I'll have to write a manual factory to put the result into the required value object without casting.

 
Replies
  • Currently Being Moderated
    Aug 5, 2010 8:42 AM   in reply to bencoderedit

    Have you tried adding an event listener that gets called when you get the result back from the web service to see if that helps? Something like:

     

    protected function myComponent_creationCompleteHandler(event:FlexEvent):void
    {
           getWebServiceResult.token = webService.webServiceMethod();
           getWebServiceResult.addEventListener(ResultEvent.RESULT, functionForResult);
    }

     

    protected function functionForResult(event:ResultEvent):void

    {

         //do something with the results returned by your web service

    }

     

    where myComponent (in this example) is the ID of the visual component where the results are being displayed. Note: I pulled this from one of my remote object calls to a ColdFusion function so the syntax might not be exactly what it needs to be for a web service call.

     

    Also, I don't know if you can use paging for something like this, like you can with a database call, but that might also be something to look into. I've not used it myself, though, so I can't help you much there.

     

    Good luck!

     

    ~ Amanda

     
    |
    Mark as:
  • rtalton
    1,133 posts
    Oct 28, 2008
    Currently Being Moderated
    Aug 5, 2010 11:35 AM   in reply to bencoderedit

    Can you post the code where you are doing the casting? Is there a loop involved in this function, or some other processing going on?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 12, 2010 1:40 PM   in reply to bencoderedit

    The performance profiler will tell you what is taking all the time, but I

    would suspect both XML parsing and base64 decoding.  The entire 800Kb XML

    response is decoded before the result handler fires.  That's a lot of nodes

    and bytes to visit.

     

    One solution is to just get the XML and parse it yourself, either using

    pseudo-threads or lazy decoding.

     

    Another is to use multiple requests that will generate smaller responses.

     

    Another is to use RemoteObject.

     

    Yet another is to use LCDS and paging.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points