4 Replies Latest reply on Aug 8, 2006 3:19 PM by KenichiM

    WebService Wierdness

    KenichiM Level 1
      I have a WebService instance created via ActionScript. If I call an operation on the WebService immediately after the WSDL is loaded the operation will fail with the error "not resolvable...WSDL.BadElement. However if I put a delay of 100 milliseconds in, the operation will succeed. Any suggestions? See the code below:

      public function newService():void
      {
      this._service = new mx.rpc.soap.WebService();
      this._service.useProxy = false;
      this._service.wsdl = kWSDLUrl;
      this._service.addEventListener(LoadEvent.LOAD, onWsdlLoaded);
      this._service.addEventListener(FaultEvent.FAULT, onFault);
      this._service.loadWSDL();
      }

      public function onWsdlLoaded(event:LoadEvent):void
      {
      var service:WebService = this._service;

      function _delay():void
      {
      service.doSomething();
      }

      // This will fail
      service.doSomething();

      // However this will succeed
      setTimeout(_delay, 100);
      }

      public function onFault(event:FaultEvent):void
      {
      if(null != event.fault) Alert.show(event.fault.message);
      }