I am developing an AIR application with Flex Builder that requires me to make two HTTPService requests at the same time. They both use different instances of the HTTPService AS3 class. Both services are calling a RESTful API which is currently running on my localhost (XAMPP) and takes a few seconds to respond (much quicker on live server).
The problem is that most of the time one of the calls fails, however occasionally they do both work. Its also random as to which call will fail.
Thanks in advance,
Chris
Both calls use code something like this. This code is basically repeated in two classes.
//in constructor
brokerageService = new HTTPService();
brokerageService.resultFormat = HTTPService.RESULT_FORMAT_E4X;
brokerageService.addEventListener(ResultEvent.RESULT, onBrokerageResult);
brokerageService.addEventListener(FaultEvent.FAULT, onFault);
//call
public function findBrokerages(type:String, value:String):void{
var url:String = serviceURL + "Contacts/findBrokerage/" + type + "/" + value + ".xml";
brokerageService.url = url;
brokerageService.send();
}
//response
private function onBrokerageResult(e:ResultEvent):void{
var response:XML = brokerageService.lastResult as XML;
etc...
}
// handle error
private function onFault(e:FaultEvent):void{
trace(e.target + " " + e.target.url);
trace(e);
dispatchEvent(new ServiceEvent(ServiceEvent.CONNECTION_PROBLEM, true));
}