8 Replies Latest reply on Jan 22, 2008 4:57 PM by Tigomark

    HTTPService.send() only works the first time

      I have the follow HTTPService defintion in my mxml page:
      useProxy="false" result="onSuccessEvent(event)" fault="onFailEvent(event)">

      Here is my call:
      updateRequest.request.id= myid;
      updateRequest.request.sname= myname;
      updateRequest.request.value = myvalue;
      updateRequest.request.randomNum = Math.random();

      The first time call is successful, but second time(after 30 seconds), after send() function call, I didn't even received HTTPService call from server side. Is this somehow cached or I need to reinitial it? This looks strange.
        • 1. Re: HTTPService.send() only works the first time
          I think is browser cache related proxy. I have the same problem but i haven`t yet tested.
          So i think, at the server, you must notify the browser/flash engine not to cache the result by specifying a header on server response like "Content-Expires 0" or equivalent. The problem seems to be only in IE, not in Mozilla. Also, setting useProxy to false will not work for IE, because of course is false by default and in your code you haven`t set to true.

          Another thought: Event not specified, i supose the prefered method to pass parameters with httpservice is via send method ( send(parameters) ) because all examples i found on flex docs are based on simple object wich contain pairs name=> value and wich is pass as parameter to send method. I don`t know if there are any significant difference using mx:request or as3 equivalent as in your example. Maybe it was prefered because is so similar to Ajax requests.
          • 2. Re: HTTPService.send() only works the first time
            I was seeing the same thing when I'd call a jsp with the same parameter list (the jsp is never re-called, and the cached results from the initial call are returned).

            you need to add

            response.setHeader("Cache-Control", "max-age=0, must-revalidate");

            to the top of your jsp. that did the trick for me
            • 3. Re: HTTPService.send() only works the first time
              Do you know what to put in a standard HTML response, in order to achieve the same end?

              • 4. Re: HTTPService.send() only works the first time
                lian360 Level 1
                Interesting, in my original message, I used "randomNum" to make sure each time the request has different randomNum to make parameters unique. Doesn't that make browser think it is different URL and won't cache it?
                • 5. Re: HTTPService.send() only works the first time
                  The random number I have found is not always that random and sometimes you will get back a cached page and not know it. Try using monthdayyearhourminutesecond and you should never get the same number.
                  • 6. Re: HTTPService.send() only works the first time
                    m_hartnett Level 3
                    I agree with telintel.
                    We use data time and have not had a problem.

                    var dt : String = new Date().toTimeString();
                    this.service.url = this.service.url + "?submitDate=" + dt;
                    • 7. Re: HTTPService.send() only works the first time
                      lian360 Level 1
                      Thanks for the answers, I eventually found out it is the updateRequest.request.value too long, probably beyond the HTTP GET limit. That is why my request was never sent out. But surprisingly, there is no error or warning from Flex. After I use HTTP POST, everything seems working ok.

                      • 8. Re: HTTPService.send() only works the first time
                        Tigomark Level 1
                        I am having the same issue but have already been using the post method. When I click my refresh button or if the timer I have set up resets I see no request made to the server.

                        private function onResult(Event:ResultEvent):void {
                        var myNum:int = Math.round(Math.random() * 2);
                        var xmlResult:XML = XML(Event.result);
                        _xlcMyListData = new XMLListCollection(xmlResult..asset);


                        <mx:HTTPService id="tempXML" resultFormat="e4x" result="onResult(event)" method="POST" url=" http://mysite.net/info_wrapper.php?customer={customer.text}&amp;username={username.text}&a mp;password={password.text}" useProxy="false"/>

                        <mx:TileList dataProvider="{_xlcMyListData}" labelField="fleet" left="35" right="15"
                        width="350" backgroundColor="#000000" color="#ff0000" fontSize="27" borderColor="#000000" columnWidth="315" rowHeight="50" themeColor="#808080" fontWeight="bold" allowMultipleSelection="true" id="TileList1" height="0" y="202" x="178"/>

                        <mx:Button label="Refresh Page Now" height="27" fillAlphas="[1.0, 1.0]" fillColors="[#030000, #030000, #474545, #474545]" borderColor="#DCDEDF" click="tempXML.send();"/>