I find myself trying to debug Amazon.com web service calls frequently, so I
wrote a little function to dump the SOAP package that Amazon.com sends me.
I thought I'd post it here so others could use it and/or give me feedback on
it. It's pretty basic, but has been a huge help while developing apps based
on Amazon's web services. I'm certainly open to criticism. I based this
code on Chris Benson's "DumpVar" function at CFLIB.ORG.
<cfscript>
function dumpAmazonDetails( myObj ) {
var counter = 1;
var currItem = "";
var currObj = myObj;
var StartString = "";
var EndString = "</table>#chr(10)#";
if ( isArray( currObj ) ) {
if ( isSimpleValue(currObj[1]) ) {
return ArrayToList(currObj);
} else {
StartString = "#chr(10)#<table
bordercolor='##008000' border='1' cellspacing='0'
cellpadding='1'>#chr(10)#";
for ( counter = 1; counter LTE ArrayLen(currObj);
counter = counter + 1 ) {
StartString = StartString &
"<tr>#chr(10)#<td bgcolor='##cceecc'
valign='top'>#counter#</td><td>#dumpAmazonDetails(currObj[counter])#</td>#ch
r(10)#</tr>#chr(10)#";
}
return StartString & EndString;
}
} else if ( isObject( currObj ) ) {
StartString = "#chr(10)#<table bordercolor='blue' border='1'
cellspacing='0' cellpadding='1'>#chr(10)#";
for ( currItem in currObj ) {
if ( currItem NEQ "TypeDesc" ) {
if ( structKeyExists( currObj, "#currItem#"
) And Len(Trim(Evaluate("currObj.get#currItem#()"))) NEQ 0 ) {
StartString = StartString &
"<tr>#chr(10)#<td bgcolor='##aaaaee'
valign='top'>#currItem#</td>#chr(10)#<td>#dumpAmazonDetails(Evaluate("currOb
j.get#currItem#()"))#</td>#chr(10)#</tr>#chr(10)#";
}
}
}
return StartString & EndString;
} else if ( isSimpleValue( currObj ) ) {
return currObj;
} else {
return " ";
}
}
</cfscript>
Ryan Hagan
ph: 540-731-3588
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

