Skip navigation
lian360
Currently Being Moderated

HTTPService.send() only works the first time

Aug 27, 2007 5:42 PM

I have the follow HTTPService defintion in my mxml page:
<mx:HTTPService
id="updateRequest"
url="{accessURL}"
useProxy="false" result="onSuccessEvent(event)" fault="onFailEvent(event)">
<mx:request>
<username>{userName}</username>
<password>{password}</password>
<id></id>
<sname></sname>
<value></value>
<randomNum>0</randomNum>
</mx:request>
</mx:HTTPService>


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

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.
 
Replies
  • Currently Being Moderated
    Aug 28, 2007 11:40 PM   in reply to lian360
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2007 7:46 AM   in reply to lian360
    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
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 29, 2007 6:14 AM   in reply to JasonBrownAA
    Do you know what to put in a standard HTML response, in order to achieve the same end?

    Thanks,
    -db
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 27, 2007 5:26 AM   in reply to lian360
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 27, 2007 5:36 AM   in reply to lian360
    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;
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 22, 2008 4:57 PM   in reply to lian360
    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;userna me={username.text}&amp;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();"/>


     
    |
    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