troubleshooting Question

Flex WebService and HTTPService Result Event not firing when created programmatically.

Avatar of recruitit
recruitit asked on
Web Languages and StandardsAdobe FlashApache Flex
11 Comments1 Solution1616 ViewsLast Modified:
When programmatically instantiating a WebService or HTTPService, the ResultEvent does not fire at all.  Using the exact same settings but installed created declaratively in mxml works totally fine, its just when created in actionscript that it doesnt work.
// Programmatic declaration

public class ServiceProxy
{
private var service:WebService;

public function ServiceProxy(){

service = new WebService();
service.wsdl = "http://www.domain.com/service.asmx?wsdl";

// used for authentication
var qname:QName = new QNAME("http://www.domain.com/", "Header");
var header:SOAPHeader = new SOAPHeader(qname, {});
var content:XML = <AuthHeader insert xml here </AuthHeader>;

header.content = content;
service.addHeader(header);

// add the event listener
service.addEventListener(ResultEvent.RESULT, serviceResultHandler);
}

private function serviceResultHandler(event:ResultEvent):void{

}

public function runService(value:String):void{
service.methodName(value);
}
}



// mxml declaration

<s:WebService id="service"
 			wsdl="http://www.domain.com/service.asmx?wsdl"
			result="webservice1_resultHandler(event)" />

protected function webservice1_resultHandler(event:ResultEvent):void{
}

protected function button_clickHandler(event:MouseEvent):void{
var qname:QName = new QName("http://www.domain.com/", "Header");
var header:SOAPHeader = new SOAPHeader(qname, {});
var content:XML = <AuthHeader xml goes here </AuthHeader>;
				
header.content = content;
service.addHeader(header);
service.methodName(value.text);
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros