0 Replies Latest reply on Jul 25, 2009 1:45 PM by mitrox

    Web services problem




      I am using Flex3 and I have encountered the following problem. I have several web services I want to use one after another (waiting for each one to finish before calling the next).


      I found this doc

      http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=dataservices_099_23.html

      From what I understood from it is that I have to set a result listener for my web service first and then in the result handler to call the second service I wish to execute.


      So I wrote something like a recursive function that does that. I have a function called useWebService which selects one of three webservices and then calls it. After this in the result listener I just call recursively useWebService again and select another service. The thing is that my recursion doesn't seem to function properly.


      I wanted to ask if anyone has already encountered this problem and how did you solve it and is also the logic behind my idea correct?






      Here's a pseudo for what I did:


      public function useWebService(strArg:String, opperations : Array):void {
                  var aOp : String;
                  userID = strArg;
                  if (flag == false) {init(); flag = true;}
                  if ((iter < OPs.length) && (OPs != null)){
                      aOp = OPs[iter].toString();
                      iter = iter + 1;
                      if (aOp == "login")

                      if (aOp == "newObervation")

                          ws.newObservation(userID, "test");
                      if (aOp == "logoff")


              public function resultHandler(event:ResultEvent):void {

                  text1.text = event.result.toString();

                  useWebService(userID, OPs);


              public function faultHandler(event:FaultEvent):void {
                    Alert.show(event.fault.message, "Error");