form
scope to a web service method that expected a struct. He got an obscure Axis error saying that the argument (form
) could not be serialized. He found that if he duplicated form
scope, it worked. He later found that if he tried to use structCopy()
instead, it didn't work and he got the same serializable error. To really see why, you need to dig into Java a little bit: for any variable (and many expressions) in ColdFusion you can find out the underlying Java type by calling
getClass().getName()
on it: form.getClass().getName()? #form.getClass().getName()#
structNew().getClass().getName()? #structNew().getClass().getName()#
duplicate(form).getClass().getName()?
#duplicate(form).getClass().getName()#
structCopy(form).getClass().getName()?
#structCopy(form).getClass().getName()#
If you run that code, you'll get this output: structNew().getClass().getName()? #structNew().getClass().getName()#
duplicate(form).getClass().getName()?
#duplicate(form).getClass().getName()#
structCopy(form).getClass().getName()?
#structCopy(form).getClass().getName()#
form.getClass().getName()? coldfusion.filter.FormScope
structNew().getClass().getName()? coldfusion.runtime.Struct
duplicate(form).getClass().getName()? coldfusion.runtime.Struct
structCopy(form).getClass().getName()? coldfusion.runtime.LocalScope
We can see from this that structNew().getClass().getName()? coldfusion.runtime.Struct
duplicate(form).getClass().getName()? coldfusion.runtime.Struct
structCopy(form).getClass().getName()? coldfusion.runtime.LocalScope
form
is not a struct even it plays one on TV. We can also see that duplicate(form)
does return a struct but structCopy(form)
does not. This subtle difference doesn't matter when you're passing
form
directly to a function that expects a struct because CFMX understands the magic behind a scope, but when you pass it to a web service, you're relying on Axis to be able to serialize the object... and Axis does not understand the magic.

0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment