8 Replies Latest reply on Jun 19, 2007 4:27 PM by cbarbara

    is it possible to make synchronous web service calls?

    mxc4 Level 1
      Hi all,

      Is it possoble to get a web service call to block and wait for a response rather than doing it asynchronously using flex/action script?

      thanks
        • 1. Re: is it possible to make synchronous web service calls?
          JKohn99 Level 1
          No, as far as I know it is not possible. It gets a bit tricky when you need to get the results of call A before you do function b. You need to do this with events instead of synchronous calls. I believe this is related to how the browser work as well.
          • 2. Re: is it possible to make synchronous web service calls?
            peterent Level 2
            What JKohn99 says is true - the calls are asynchronous. They have to be. You are making a call over a network and you have no guarantee when the result will come back, if at all. If you need to chain calls, have the result handler of the first call invoke the next call and so on.
            • 3. Re: is it possible to make synchronous web service calls?
              mxc4 Level 1
              As far as I know the HTTPXMLRequest method can make synchronous or asynchronous calls. So it should be possible in flex unless its been specifically designed not to do this.

              All it really means is that the flash application must wait until the callback is called before proceeding. It should be possibe to wrap this somehow?

              I have a work around for now.
              • 4. Re: is it possible to make synchronous web service calls?
                Sean Hughes
                peterent - no offense, but your suggestion is a hack. All we need is a timeout value. This should be supported natively in Flex, but its not. If anyone has some code that implements a synchronous Web Service call in Flex, please post it here. TY.
                • 5. Re: is it possible to make synchronous web service calls?
                  peterent Level 2
                  You can use XMLHttpRequest with FABridge - the Flex/Ajax bridge.
                  • 6. is it possible to make synchronous web service calls?
                    Fireteller
                    quote:

                    Originally posted by: Sean Hughes
                    peterent - no offense, but your suggestion is a hack. All we need is a timeout value.


                    In support of the flash player's design I'm going to have to disagree with you here. It is completely normal in any multi threaded environment to make all functionality non blocking by default. Blocking by design can be implemented with semaphores, and is not a hack. To implement simply create a flag such as 'hold:bool' init it to false when your application starts. Set it to true just before the web services send() method is called. In the result handler you set it back to false.

                    In this way you have complete control over what should be blocked and what should not be blocked, by simply testing the 'hold' semaphore. In this way the GUI itself, and all non dependent functionality stays alive. A timeout value would arbitrarily block all functionality for a fixed amount of time if the request was never filled. Although a semaphore could be used to do this as well, it has far more flexibility, and users have notoriously shorter timeout values than developers.

                    j
                    • 7. Re: is it possible to make synchronous web service calls?
                      Sean Hughes Level 1
                      Just wanted to say thanks Perterent and mxc4 for the solution. What I was trying to say with my previous "hack" comment was that there should be a way to support synchronous calls and many programmers do prefer to make synchronous calls to services if they can. At the time I wasn't aware of the FABridge at all, so I thought there was no solution other than to have to write a ton of async web service code.

                      Since then, I've used and extended the FABridge framework and have written a number of Flex web service classes that facilitate making synchronous web service calls, including timeouts, etc. So thanks.
                      • 8. Re: is it possible to make synchronous web service calls?
                        cbarbara
                        I see that the FABridge is included in the LiveCycle Data Services ES, is the FABridge Framework free?
                        Is there a way to just download the FABridge framework that i am missing?
                        I would love to be able to call web services synchronously without having to buy a license for LiveCycle Data Services.

                        Thanks,
                        Chris