Gotcha with WDDX and The Array Datatype
Related Categories: ColdFusion
As it turns out, coldfusion.runtime.Array datatypes turn into java.util.Vector datatypes after WDDX deserialization. This isn't much of a problem for the most part. After all, the CFMX Array datatype is based on the Java Vector datatype. CF still views it as an array, and you can still treat it just like an array in CF code.
However, there is at least one place it *does* matter - invoking and consuming webservices. It seems that when one of these java.util.Vector datatypes is passed to certain webservices, you will get the infamous and annoyingly indescriptive error that it "Could not perform web service invocation "X" because java.lang.IllegalArgumentException: argument type mismatch".
Yowza.
I've confirmed the behavior with some folks at Adobe, so hopefully it will be corrected with the Scorpio release. In the meantime however, I am getting around this problem by recreating/rebuilding the array before posting it to the webservice. A little annoying, but it works.
If you want to test this gotcha yourself, here's some sample code to play with:

mate, can I be a pest and ask you for a couple of details to elaborate on the problem...?
you saying that you found certain webservices can't handle
*java.util.Vector* but they hads no problem with *coldfusion.runtime.Array* ?
yes?
I'm curious: how complex was the rest of the data needed by the webservice? was it written in .NET (that you know of) or was it one you wrote that you wanted to plug in/consume?
as an aside, we've had our fair share of grief with some webservices ( esp .NET ones: see http://www.corfield.org/blog/index.cfm/do/blog.ent...)
and while what you've found isn't related, I gotta keep up to speed/be prepared for any "gnarly" details.
sorry to be a pain
thanx
This is the call:
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">...;
<soapenv:Body>
<test2 xmlns="">
<item>
<nr>1234</nr>
<action>1</action>
</item>
<item>
<nr>5678</nr>
<action>2</action>
</item>
</test2>
</soapenv:Body>
</soapenv:Envelope>
And this is the webservice:
<cfcomponent displayName="XY">
<cffunction name="test2"
access="remote"
returntype="numeric" output="true">
<cfargument name="item"
type="array"
required="true" />
<cfdump var="#arguments#">
<cfreturn 0 />
</cffunction>
</cfcomponent>
All the caller gets is an "Internal server error" - type="array" doesn´t seem to work here. What can I do?
Best regards,
Rüdiger
<cffunction name="test2"
access="remote"
returntype="numeric"
output="false">
<cfargument name="atest"
type="array"
required="true" />
<cfset arguments.returncode = 0>
<cfreturn arguments.returncode />
</cffunction>
It has to do with the parameter type of "array"...
http://cfdj.sys-con.com/read/86131.htm
-Cameron