thanks Raj
On Tue, Jun 11, 2013 at 3:13 PM, Raj U. Shaikh <[email protected]>wrote: > Sumudu, > > Try googling on "Responder", "AsyncToken" and "AsyncResponder" class. > It will help you to make your call asynchronous. > > Thanks & Regards, > Raj Shaikh > > -----Original Message----- > From: Sumudu Chinthaka [mailto:[email protected]] > Sent: Tuesday, June 11, 2013 3:00 PM > To: [email protected] > Subject: Re: Async call inside a class > > 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 > >> ______________________________**______________________________** > >> __________ > >> > > > > > MASTEK LTD. > In the US, we're called MAJESCOMASTEK > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Opinions expressed in this e-mail are those of the individual and not that > of Mastek Limited, unless specifically indicated to that effect. Mastek > Limited does not accept any responsibility or liability for it. This e-mail > and attachments (if any) transmitted with it are confidential and/or > privileged and solely for the use of the intended person or entity to which > it is addressed. Any review, re-transmission, dissemination or other use of > or taking of any action in reliance upon this information by persons or > entities other than the intended recipient is prohibited. This e-mail and > its attachments have been scanned for the presence of computer viruses. It > is the responsibility of the recipient to run the virus check on e-mails > and attachments before opening them. If you have received this e-mail in > error, kindly delete this e-mail from desktop and server. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >
