4 Replies Latest reply on Sep 1, 2009 3:05 AM by Andrew Rosewarn

    Is reloading of HTTPService cached?

    ikevinTV

      I'm trying to use HTTPService to repeat load some JSON data via a Web Services GET call. It seems that the result is cached and never hits the server. Does anyone know how to "force" HTTPService to really reload from the server?

      Thanks!

      Kevin.

      The code is below:

      public class ContactListClass extends Canvas
      {

      public var contactsListataGrid;
      public var contactsData:ArrayCollection;

      public var getContactsHTTPService:HTTPService;

      public function ContactListClass()
      {
      super();
      init();
      addEventListener(FlexEvent.UPDATE_COMPLETE, enterEventHandler);
      }

      private function enterEventHandler(event:FlexEvent) : void {
      loadDataGrid();
      }

      private function init() : void {
      contactsList = new DataGrid();
      contactsData = new ArrayCollection();
      contactsList.dataProvider = contactsData;
      getContactsHTTPService = new HTTPService();
      loadDataGrid();
      }

      private function loadDataGrid() : void {
      getContactsHTTPService.url="http://localhost:8181/JServer/resources/Contacts/Recruiter/-1/Company/-1/PreferredLanguage /0";
      getContactsHTTPService.useProxy=false;
      getContactsHTTPService.method="GET";
      getContactsHTTPService.resultFormat="text";
      getContactsHTTPService.addEventListener(ResultEven  t.RESULT, processJSONData);

      var encoder:Base64Encoder = new Base64Encoder();
      encoder.encodeUTFBytes("ikevinassword");
      getContactsHTTPService.headers["Authorization"] = "Basic " + encoder.toString();
      getContactsHTTPService.headers["Accept-Language"] = resourceManager.localeChain.toString();

      getContactsHTTPService.send(null);
      }

      private function processJSONData(event:ResultEvent): void {
      var rawData:String = String(event.result);
      var dataArray:Array = (JSON.decode(rawData) as Array);
      var dataArrayCollection:ArrayCollection = new ArrayCollection(dataArray);
      contactsList.dataProvider = dataArrayCollection;
      Alert.show(rawData);
      }
      }

      }