Flex 3.0 Introspecting Utility: Handling Collections Bug

adminTechnical TipsLeave a Comment

Even Flex Builder with all its awesomeness is not without its own set of quirks. It seems the introspecting utility does not handle collections(arrays, arraylist, string[]) properly.

My Example Problem and Solution

Following is a simple example:

  • I had written a java webservice that takes a Array of a custom object and loads it to the database.
  • I tested the webservice by itself and it worked.
  • I used the Flex Builder’s Introspecting utility to integrate my Flex Application with my webservice.
  • I had added the client side code to invoke the webservice with the appropriate data and tested it.
  • It failed miserably.

The problem was with the objects that Flex sent to the webservice. After long hours of debugging, I noticed that the objects I had received in my service, even though a collection, were serialized in a format Java was unable to understand. They were objects, but i was unable to cast or convert them.

I decided to modify my Java webservice to accept a String[], as I assumed my problem was with a collection of objects. I modified my client application to convert all the data in the model to a colon-delimited-string and passed a String[] to my webservice.

This is when the real problem showed itself; I noticed that in my webservice all strings in the arrays were concatenated into one huge ‘comma-delimited-string’. After realizing what the introspecting utility was doing to the String[], I just had to make some minor modifications to the webservice to get it to work.

Conclusion

There is still a problem with Arrays of Custom Objects. Please check the ‘Adobe Bug Database’ to see related bugs. For now, the only work around as i see it would be to use BlazeDS for your webservice integration. It is a middle-layer for your environment, it externalizes the webservice connections, and has a better messaging framework as well as more feature. I feel it is a good choice, even if Adobe does fix this issue.

Leave a Reply

Your email address will not be published. Required fields are marked *