Gotcha with WDDX and The Array Datatype

Posted At : January 18, 2006 8:04 PM | Posted By : Cameron
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:

Comments
barry.b's Gravatar Hi Cam

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
# Posted By barry.b | 1/19/06 4:03 PM
Cameron Childress's Gravatar I am not 100% sure what language the webservice was written in, but I think it may have been Java. The array was part of quite a lot of complex structured data being passed to it so I'm unlikely to be able to isolate it down much tighter than than. Sorry I can't of more help...
# Posted By Cameron Childress | 1/19/06 11:42 PM
Rüdiger Graf's Gravatar ...I might have a related problem when creating a webservice in CF that is being called from outside (NOT written in CF):

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
# Posted By Rüdiger Graf | 2/10/06 1:52 PM
Cameron Childress's Gravatar Well, if you really left the <cfdump var="#arguments#"> in the CFFUNCTION, then it's outputting that junk every time you call the webservice. Remove your debug code and the problem may go away.
# Posted By Cameron Childress | 2/10/06 2:03 PM
Rüdiger Graf's Gravatar ...nope, that doesn´t help - even if the CFFUNCTION tag simply looks like this, I get the mentioned error:

<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"...
# Posted By Rüdiger Graf | 2/12/06 12:27 PM
Cameron Childress's Gravatar You might want to check out Rob Munn's article on troubleshooting problems with Webservices:

http://cfdj.sys-con.com/read/86131.htm

-Cameron
# Posted By Cameron Childress | 2/12/06 4:22 PM

Recent Entries

Archives By Subject

Tech Blogs

(Mostly) Not Tech Blogs