6 Replies Latest reply on Dec 11, 2007 9:55 AM by ntsiii

    HTTPService- Multiple call with dynamic link?

    2JZ
      Hi,

      Another question from a newbie. I am trying to have 2 HTTPService link to external xml files at the same page/application. The first HTTPService open a file ( just like a content page of what datasets/ files available and which is the latest update). At the resultHandler, it will generate the external xml file path for the second HTTPService to link.

      Obviously, it is not working. When the page is luanched, it tries to link both xml files prior to the resultHandler from the first HTTPService. What should I do to go around this?

      Please help.
        • 1. Re: HTTPService- Multiple call with dynamic link?
          m_hartnett Level 3
          You need to post some code.
          How are you calling the first HttpService?
          In the result handler of the first HttpService request does the second service get called from within that handler?

          Here is a sample. It uses Cairngorm but it is exactly the same thing you are doing. The original HttpService request is performed in the show event of another window. Then this result handler executes the next request.

          public override function resultHandler( rpcEvent : Object ) : void {
          try {
          var cgEvent : ContactLoadEvent = new ContactLoadEvent();
          CairngormEventDispatcher.getInstance().dispatchEvent(cgEvent);

          }
          catch(e:Error) {
          model.msgUtil.handleErrorMsg(e);
          }

          }
          • 2. Re: HTTPService- Multiple call with dynamic link?
            2JZ Level 1
            <mx:HTTPService id="MainSrv" url="data\FileList.xml" showBusyCursor="true" useProxy="false" result="resultHandlerA(event)"/>
            <mx:HTTPService id="PieSrv" url="{DataXMLFile}" showBusyCursor="true" useProxy="false" result="resultHandlerB(event)"/>

            Note: the DataXMLFile is a string type variable where the filepath will be generated from resultHandlerA().
            It seems like the application wants to connect the second HTTP Service before the resultHandlerA() is called.
            • 3. Re: HTTPService- Multiple call with dynamic link?
              2JZ Level 1
              My goal is to luanch a page to display the content files (what files are accessble for user to read) on left and to display the latest updated file on right.

              The latest available file name can be found from the content file. That's why I need to link the content.xml with the first httpservice. At the resultHandler(), I decoded/get the latest file's name. I tried to bind it to the second HTTPService's url.

              It seems like the Flex wants to compile the linkage before running the result handler. Is it posible to luanch the function before the second HTTPService link?
              • 4. Re: HTTPService- Multiple call with dynamic link?
                m_hartnett Level 3
                Where does the initial call to the first httpservice occur?
                Can you post your code for the initial call and the handler of that call.
                What is the error you are receiving?

                The only other issue I can see is possibly a databinding issue not completing before that next call to the service is made.
                • 5. Re: HTTPService- Multiple call with dynamic link?
                  2JZ Level 1
                  mhartnett,
                  You are correct. I just have that in mind. I actually fixed it by removing the PieSrv.send() at the beginning. I just don't call it until the file path is created. Thanks! :)
                  • 6. Re: HTTPService- Multiple call with dynamic link?
                    ntsiii Level 3
                    Also note that you can use a single instance of HTTPService if you want. Look into the AsyncToken for more info.
                    Tracy