Skip to main content
Inspiring
February 4, 2010
Question

deserializtion error, coldfusion 9/flex 3.5 VO's and ORM

  • February 4, 2010
  • 2 replies
  • 3921 views

Lateley I've been receiving the following error when trying to send a VO to Coldfusion.  The CFC it's bound to is an ORM component that has foreign key properties, so I don't know if that has anything to do with it.  The same VO seems to work find when retrieving information from the database, I just can't send it back.

As far as I know I'm using the new format for the services-config file for CF 9, which I read on another post can cause the problem.  Attached is the CFC, the Actionscript VO, the services-config and the code that calls the remote object in a zip file.  Below is the error.

[RPC Fault faultString="Error deserializing client message." faultCode="Client.Packet.Encoding" faultDetail="null"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at NetConnectionMessageResponder/statusHandler()
at mx.messaging::MessageResponder/status()

Thanks for any help!  I've been stuck on this the past couple of days!

    This topic has been closed for replies.

    2 replies

    Participant
    March 8, 2010

    I encountered a similar issue to this, and I agree, it seems to be a problem, although I think it goes beyond your issue with the validation.

    The scenario plays out as follows.

    [RemoteClass(alias="SomeVO")]

    public class SomeVO {

      public var whatever:Array = null;

      public function SomeVO() { }

    }

    This gets sent to CF9, and maps to the CFC

    <cfcomponent name="SomeVO" alias="SomeVO">

      <cfproperty name="whatever" type="array"/>

      <cfset this.whatever = arrayNew(1)/>

    </cfcomponent>

    But, since whatever is null in Flex, it serializes to [empty string], and, instead of just ignoring it or whatever serialization is suppose to do when handling nulls, the type of whatever in my CFC changes from array to string. When the object is returned back to Flex, it says it cannot convert a string to an array. Well, duh! Maybe the serializer shouldn't have trampled on the data types to begin with.

    jim1234Author
    Inspiring
    March 8, 2010

    Classification: UNCLASSIFIED

    Caveats: FOUO

    A couple of things. I posted on Rupesh's blog and apparently Adobe is aware

    of the problem and working on a fix.

    To get around it for now I created my own validation routine. So I can set

    the types to "Any" in the ORM class so the Deserializer doesn't complain and I

    use my own attributes to determine the type and validation. I just put the

    routine in a base class that all the other ORM CFC's inherit from. I also

    have a "setnull" attribute that if the value comes in as a "" or a 0 then I

    use javacast to set it to null. This also allows me to send back my own user

    friendly validation messages.

    Jim

    Classification: UNCLASSIFIED

    Caveats: FOUO

    Participant
    March 19, 2010

    @jim

    Hi,

    Thanks for this info, I've been stuck on it for 2 days now... Similar error message happens to me when I send back from flex to coldfusion an object (employe) with a simple many-to-one relation (department). In my case the department is not an array but just a foreign key of the employe entity (one department has many employees)

    Could you please give more information about your workaround... provide some code...

    Do you mean that you set the type to "Any" in your relation instead of Array?

    Is there any Bug in Adobe bug database we could vote for / follow ?

    Could you send the url @ Rupesh blog ?

    Thanks

    Simon

    jim1234Author
    Inspiring
    February 5, 2010

    I figured out what is happening, but I don't know how to get around it.  I created a stripped down application for testing purposes.  I then went through my person vo and CFC one property at a time to see where the error occurred.  I found out it occurred on the email property.  My email property is defined thusly in the CFC:

    <cfproperty name="email" type="string" validate="email" column="EMAIL"/>

    Looks innoccous enough, right?  Well I have validate="email" in the property so it expects a valid email and only a valid email.  Therefore if you pass a null in it or an empty string, it barfs and you get the deserialization error, at least I do.  If I take out the validate, it works fine.  If I pass in a valid email address with the validate, it works fine.

    This brings up a few questions:

    1.  Is there a way around this?  Can I pass in a null value with a property that has validate="email"?

    2.  Why do I get a deserialization message and not a "Invalid email" type of message?

    3.  Is this a bug in Coldfusion 9?

    Attached is my stripped down application and services-config.xml.  I would appreciate someone testing this and seeing if they get the same thing.  Thanks!

    jim1234Author
    Inspiring
    February 5, 2010

    Sorry, in the Person.as VO change the type of email from Date to String.  I was messing around with it and forgot to change it back.  Thanks.