0 Replies Latest reply on Apr 3, 2007 5:07 AM by WardLoockx

    HttpService Initializes before Application preinitialize.

    WardLoockx
      Hello,

      I want to use an external url instead of hard coding my Httpservice urls in flex. Now I've try'd to read my XML file when the prinitialize event of the application is triggerd. But the problem is my HttpServices are already initialized! When I try to put my urls dynamic into my httpservice with service.url = myurl; it gives me the following error .

      quote:

      [RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.generaldata2.besite.be/searchController.php" URL: http://www.generaldata2.besite.be/searchController.php"
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::faultHandler()
      at mx.rpc::Responder/fault()
      at mx.rpc::AsyncRequest/fault()
      at ::DirectHTTPMessageResponder/errorHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::redirectEvent()



      Here is the code I used

      quote:


      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" preinitialize="preInit()"


      quote:


      private function preInit()
      {
      try
      {
      var loader:URLLoader = new URLLoader();
      loader.dataFormat = URLLoaderDataFormat.TEXT;
      loader.addEventListener(Event.COMPLETE, handleConfigComplete);
      loader.load(new URLRequest("GD_Vars.xml"));
      }
      catch(e:Error)
      {
      trace(e.message);
      }
      }


      quote:


      private function handleConfigComplete(event:Event)
      {
      try
      {
      var variables:XML = new XML(event.target.data);
      for each(var element:XML in variables.elements())
      {
      var thisKey:String = element.@name;
      var thisValue:String = element.@value;
      this._VARS[thisKey] = thisValue;
      }


      _personRequestUrl = _VARS['GD_URL']+'searchController.php';

      }
      catch(e:Error)
      {
      trace(e.message);
      }
      }