hi sorry about it here is more clear coding
public class TestDataProvider
{
private var result:Object;
public function TestDataProvider()
{
var request:URLRequest = new URLRequest();
var urlLoader:URLLoader = new URLLoader();
request.contentType = "text/xml; charset=utf-8";
request.method = "POST";
request.url = Globals.ISA_WEB_SERVICE_URL;
var SOAPAction:URLRequestHeader = new
URLRequestHeader("SOAPAction","getAvailability");
request.requestHeaders.push(SOAPAction);
request.data = avalabilitySearchReq.xmlData;
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.load(request);
urlLoader.addEventListener(Event.COMPLETE,completeHandler);
}
private function completeHandler(event:Event):void){
result = event.data;
}
public function getResult():Object{
return this.result
}
}
what i basically want to do is create of this class and call it's
getReqult() method to access the result from the webservice call
Ex var obj:TestDataProvider = new TestDataProvider();
obj.getResult();
but the problem is
completeHandler () function is never get executed and program jumps to next
instruction as soon as it reached end of constructor
how should i handle this
On Tue, Jun 11, 2013 at 2:31 PM, Tom Chiverton <[email protected]> wrote:
> The formatting in that is screwed up. Please post it somewhere where it
> stays indented.
>
> You probably want to remove all the extra stuff that has no relation to
> the issue like all the private variables and so on.
>
> Tom
>
>
> On 11/06/2013 09:31, Sumudu Chinthaka wrote:
>
>> hi
>>
>> i have a class with a webservice call in the constructor and i want to
>> handle the result upon successful execution of web service
>> but Event.COMPLETE inner function never get executed
>>
>> what should i do to make it possible
>>
>> if i place this code in UI component then it;ll get executed but once i
>> separate it to another class it doesn't work
>>
>>
>>
>>
>> [Bindable]
>> public class TestDataProvider
>> {
>> private var isReturn:Boolean = false;
>> private var originAirport:Airport = new
>> Airport().AirportInitializer("**IKA","IKA","IKA");
>> private var destinationAirport:Airport = new
>> Airport().AirportInitializer("**DUS","DUS","DUS");
>> private var departureDate:Date = new Date(2013,5,29);
>> private var arrivalDate:Date = new Date(2013,5,29);
>> private var adult:Number = 1;
>> private var children:Number = 0;
>> private var infant:Number = 0 ;
>> private var flightResult:ArrayCollection;
>> private var searchCriteria:**AvailabilitySearchDTO
>> private var transactionID:String;
>> private var priceQuotResultDTO:**PriceQuotResultDTO;
>> public function TestDataProvider()
>> {
>> searchCriteria = new
>> AvailabilitySearchDTO().**AvailabilitySearchDTOInitializ**
>> er(this.isReturn,this.**originAirport,this.**destinationAirport,this.**
>> departureDate,this.**arrivalDate,this.adult,this.**children,this.infant);
>> var avalabilitySearchReq:**AvalabilitySearchRequest = new
>> AvalabilitySearchRequest(**searchCriteria);
>> var request:URLRequest = new URLRequest();
>> var urlLoader:URLLoader = new URLLoader();
>> request.contentType = "text/xml; charset=utf-8";
>> request.method = "POST";
>> request.url = Globals.ISA_WEB_SERVICE_URL;
>> var SOAPAction:URLRequestHeader = new
>> URLRequestHeader("SOAPAction",**"getAvailability");
>> request.requestHeaders.push(**SOAPAction);
>> request.data = avalabilitySearchReq.xmlData;
>> urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
>> urlLoader.load(request);
>> urlLoader.addEventListener(**Event.COMPLETE, function (event:Event):void{
>> var asObj:Object = XmlUtility.**getObjectFromXMLTypeString(**
>> event.target.data)
>> if(asObj.Envelope.Body.OTA_**AirAvailRS.Errors == null)
>> {
>> var tmpObj:Object =
>> asObj.Envelope.Body.OTA_**AirAvailRS.AAAirAvailRSExt.**PricedItineraries.
>> **PricedItinerary.AirItinerary.**OriginDestinationOptions.**
>> OriginDestinationOption;
>> var priceInfo:Object =
>> asObj.Envelope.Body.OTA_**AirAvailRS.AAAirAvailRSExt.**PricedItineraries.
>> **PricedItinerary.**AirItineraryPricingInfo;
>> transactionID = asObj.Envelope.Body.OTA_**AirAvailRS.**
>> TransactionIdentifier;
>> if(tmpObj is ArrayCollection){
>> flightResult = tmpObj as ArrayCollection;
>> }else{
>> flightResult.addItem(tmpObj);
>> }
>> var searchResDTO:**AvailabilitySearchResultDTO = new
>> AvailabilitySearchResultDTO().**AvailabilitySearchResultDTOIni**
>> tializer(flightResult,**searchCriteria,transactionID);
>> var request:URLRequest = new URLRequest();
>> var urlLoader:URLLoader = new URLLoader();
>> var availabilitySearchResultDTO:**AvailabilitySearchResultDTO =
>> searchResDTO;
>> priceQuotResultDTO = new
>> PriceQuotResultDTO().**PriceQuotResultDTOInitializer(**
>> availabilitySearchResultDTO);
>> }
>> });
>> }
>>
>>
>> ______________________________**______________________________**
>> __________
>> This email has been scanned by the Symantec Email Security.cloud service.
>> For more information please visit http://www.symanteccloud.com
>> ______________________________**______________________________**
>> __________
>>
>
>