2 Replies Latest reply on Jul 26, 2006 6:37 PM by Vision Airlines

    Problem in getting data by using HTTPService

    ncelq
      Hi All,

      A http request: http://127.0.0.1:8001/getData.do will get the following XML result set:

      <data>
      <doc>
      <id>AC3323</id>
      <code>AC3323</code>
      <status>Active</status>
      </doc>
      </data>


      By using HTTPService:

      <mx:HTTPService id="dataSrv" url=" http://127.0.0.1:8001/getData.do" useProxy="false" method="POST" showBusyCursor="true"
      fault="Alert.show('Connection Error!')">
      </mx:HTTPService>

      <mx:Button label="Get Record" click="dataSrv.send();"/>

      the result will then bind to a datagrid after the button is clicked

      The problem is that once i change the record to status=Inactive in the backend, and i click the button again, the record is still status=Active (it seems to me that the HTTPService get the cache data instead of posting the record again to the server). I have to reload the full page and click the button again so as to get the right status (i.e. Active status)

      How could i fix this problem?

      Regards,
      ncelq
        • 1. Re: Problem in getting data by using HTTPService
          ntsiii Level 3
          First try setting the caching headers on the server:
          <META HTTP-EQUIV="Cache-Control" CONTENT ="no-cache"> <META HTTP-EQUIV="expires" CONTENT="0">Or from a JSP page, try the following before writing anything to the output stream:

          response.setHeader("Cache-Control","no-cache");
          response.setDateHeader ("Expires", 0);
          or
          response.setHeader("Cache-Control", "max-age=0, must-revalidate");

          If that does not work, build you url in AS code and append a parameter that will always be unique. For example:
          var url : String = " http://www.server.com/file.php"; url += "?" + String ( Math.random() * 9999) ;

          Some people use Date instead of the random number.

          Tracy
          • 2. Re: Problem in getting data by using HTTPService
            Vision Airlines
            I thought I was the only one. I'm having the same problem ncelq. I haven't had the chance to try the above, but if you get any of these to work please post an example.