2 Replies Latest reply on Aug 4, 2006 5:32 PM by ntsiii

    HTTPService error  help?

    avanthika
      Hi all,
      I am doing an application to get data from the server using HTTPService.
      I have an arraycollection containing all vehicle id's , For each vehicle id , contains many vehicles with different colors. i have to pass each vehicle id to server to get the image urls for all vehicle images of that vehcle number.

      so i am sending a query with vehcle id using httpservice, and on result event of HTTPService, i am storing that urls in an array and again executing HTTPService.send with different vehicle id URL.
      This is working fine , if all urls execute successfully.
      My problem is , suppose any time for any vehicle id query fails , HTTPService Fault event is executing, After this i am not able to continue sending url's for other vehicles id. My application is stoped thier.
      Since i am executing the next vehicle id query on Result event. If Fault event raises how to ignore that and execute further.

      I am placing my code here.


      public var vehicle_arr:ArrayCollection=new ArrayCollection;
      public var cnt:int =0;
      // vehicle_arr contains all vehicle numbers, for each vehicle number there are different vehicle images are their,
      // i have to pass this vehicle_id to get image url 's of that vehicle number from the server.
      public function getImgPath():void{ imgPathUrl=" http://www.xyz.com/flashhandler.aspx?Query=exec dbo.viewGetVehicles ‘"+vehicle_arr[cnt].vehicle_id+"’"
      var token:AsyncToken = AsyncToken(ImgPathsrv.send());
      token.addResponder(new TokenResponder(getPhotoPath));
      }

      public function getPhotoPath(event:ResultEvent ) :void{
      imgPath_arr=ImgPathsrv.lastResult.NewDataSet.Table
      for(var i:int=0;i<imgPath_arr.length;i++){
      img_arr.addItem({image:imgPath_arr .PhotoPath});
      }
      cnt++;
      if(cnt<vehicle_arr.length){
      getImgPath();
      }
      }

      <mx:HTTPService id="ImgPathsrv" url="{imgPathUrl}" showBusyCursor="true" />



      // for token responder class i created a actionscript file which i am calling above.

      package ascript
      {

      import mx.controls.Alert;
      import mx.rpc.IResponder;
      import mx.rpc.events.FaultEvent;

      /**
      * A simple responder that will call the result function specified but
      * handles any fault by simply raising an Alert with the specified title.
      */
      public class TokenResponder implements IResponder
      {
      private var resultHandler:Function;
      private var faultTitle:String;

      public function TokenResponder(result:Function, faultTitle:String=null)
      {
      super();
      resultHandler = result;
      this.faultTitle = faultTitle;
      }
      public function result(data:Object):void
      {
      resultHandler(data);
      }

      public function fault(info:Object):void
      {
      //the info object from an AsyncToken is always a FaultEvent
      Alert.show(FaultEvent(info).fault.toString(), faultTitle);
      }

      }

      }



      Any one please help me how to ignore fault for that url and continue sending other url's to the same httpservice.

      Thanks in advance

      Regards
      Avanthika