Whew, no small title!
I was answering some emails today and the topic of error reporting came up. Basically the person was wondering why Flash always reports the same error message for WebServices:
Error opening URL "http://www.flash-mx.com/ws/tipoftheday/tip.cfc?wsdl"
No matter what the error could be in the Flash app (bad bindings, no bindings, bad URL, etc), the error message always reports "Error opening URL".
After a bit of investigation, and a few trips to livedocs.macromedia.com, I managed to piece together the following short example. The only prerequisite (apart from Flash MX Pro 2004) is that you have a WebServiceConnector component in your library.
import mx.services.*;
//_global.__dataLogger = new mx.data.binding.Log();
var my_log:Log = new Log();
my_log.onLog = function(txt:String) {
trace(txt);
};
var myWebServiceObject:Object = new WebService("http://www.flash-mx.com/ws/tipoftheday/tip.cfc?wsdl", my_log);
var myPendingCallObject:Object = myWebServiceObject.getCurrentTip();
myPendingCallObject.onResult = function(result:Object) {
trace("\n\nTip received.");
/*
for (var prop in result) {
trace(prop+":"+result[prop]);
}
*/
};
myPendingCallObject.onFault = function(fault:Object) {
trace(fault.faultCode+","+fault.faultstring);
};
It is probably worth mentioning that both the Log class and the WebService class are contained within the mx.services.* package. So, if you want to avoid an import statement, you need to qualify the Log class with mx.services.Log. Likewise with the WebService class, which you need to change to mx.services.WebService.
Anyways, hopefully somebody out there finds that useful in some small way.
Posted by jen on July 15, 2004 at 12:11 PMThe Log class is definitely a valuable tool, I generally like to change my debugging levels through development. I did however find that you will still get some generate endpoint errors etc if the http header is an error header like some webservices will set. When getting endpoint errors it is sometimes best to just look at the response yourself (and not depend on Flash's interpretation) you can do this via PendingCall.response
Posted by: Greg Burch at July 15, 2004 05:35 PM