Creating an HTTPService not through a tag is not officially supported right now.  I don’t remember if not calling initialized will actually hurt you, mostly it would screw up validation if you had any but I think it should be OK.  The bigger problem is that you’re trying to access the result too quickly.  You need to do it in a result handler (addEventListener(“result”)) since the call is asynchronous.  Don’t forget to use Delegates.

 

Matt

 


From: billheit [mailto:[EMAIL PROTECTED]
Sent: Monday, February 21, 2005 1:05 PM
To: [email protected]
Subject: [flexcoders] Instantiate an HTTPService object in ActionScript

 


I am trying to create a custom component to manage my Web Services. 
So far I have created a class that contains a variable of type
mx.servicetags.HTTPService as follows:


class DataManager extends Object{
      public var requestService:mx.servicetags.HTTPService;
      public function ASDataManager(){
            super();
            // mx.servicetags.HTTPService.initialize()
            requestService = new mx.servicetags.HTTPService()
            requestService.url
= "http://bheitstuman03/GBOS/ObjectService.asmx/requestObjects"
            requestService.method = "get"
            requestService.resultFormat = "object"
            var params:Object = new Object()
            params.objectXML = ""
            params.credentials = "UserBob;BobsPassword"
            requestService.request = params
            requestService.addEventListener("fault",
this.handleFault);
      }
      public function getData(){
            requestService.send()
            var test:Object
            test = requestService.result
      }
      public function handleFault(event):Void{
            trace("Send Fault");
      }

}

However, when I create an instance of this above DataManager and
call the getData method, it doesn't work.  After stepping through
the code, I noticed that it does call the HTTPService's send method
but the local _document variable has no value.   I also noticed that
the initialized function sets this variable's value as follows:

public function initialized(document : Object, id : String) : Void
    {
        _id = id;
        _document = document;
    }


Does anyone know how to instantiate a working HTTPService object
within ActionScript?






Reply via email to