CF7, Web Services, and null

I discovered today (after many hours of debugging), that if you have
web service method declared to return 'any' on CF6.1, you can return
null without incident.  However, if you're on CF7, it causes an
NPE to be thrown.  To illustrate what I mean, take this
[abbreviated] code:

That function will work happily if served by CF6.1 and consumed by
CF6.1 and CF7.  However, if it's served by CF7, it will error
out.  The solution is to do something like this:


The structKeyExists call is checking for null (it will return false
if the key exists but has a null value – something that I'm not sure is
documented anywhere).  If the result is null, it's reset to the
empty string before being returned.

Note that non-web service
method invocations on CF7 can return null with a declared returntype of
'any' without incident; this is a web services-only problem.

online casino real money nz

2 responses to “CF7, Web Services, and null”

  1. Danilo

    And what would best to do if an empty string is a valid return for the function?

  2. Barney

    Pick something else, then. My point was more that you can't return null if your function says it'll return "any". Any non-null value will work, I just picked the empty string because it's often used (in CF) as an alias for null.

    If nothing else, return "–NULL–" or something, and then you can check it on the recieving end. Theoretically that shouldn't ever be a valid return value, right?