CFC Results Via AMF And Case Inconsistencies

I just spent a long time troubleshooting a Flex ColdFusion connectivity issue, and now that we’ve figured out what was going on I am sharing this in case it bites anyone else.
There are two basic ways for Flex to invoke back-end ColdFusion CFCs, SOAP (Web Services) or AMF (Flash Remoting). My app had been using SOAP, but I needed to convert to AMF (the performance difference is significant).
Last year Brandon Purcell wrote an excellent blog entry entitled Switching between webservices and Flash Remoting using Flex, and so I used his steps to make the switch. As he notes in that entry, ColdFusion variables returned via SOAP have their names converted to uppercase, whereas variables returned via AMF retain their original case, and so any binding code (or Flex code referencing returned data) needs to be converted from all caps to actual case.
The converted code worked perfectly for CFC methods returning queries, they ran exactly as they did before, just a whole lot quicker. But my CFC methods returning structures all failed, none of my bindings and client-side code worked.
The problem? Waldo Smeets figured this one out, unlike returned queries, returned structure members are all caps, even when using AMF. This is horribly inconsistent, and hopefully it’ll be fixed in the future. For now, keep this in mind.

3 responses to “CFC Results Via AMF And Case Inconsistencies”

  1. Vinny Timmermans Avatar
    Vinny Timmermans

    Ben, this is fixed in CFMX 7. Make sure <lowercase-keys>true</lowercase-keys> in the gateway-config.xml file. This will allow ColdFusion to look up keys case insensitively, and will not actually change the case of the keys

  2. Tracy Logan Avatar
    Tracy Logan

    This is related to a long-time inconsistancy with structs and capitalization: Using array-notation yields keys with the specified case, while dot-notation results in upcased keys. You can see this easily with a simple test:
    test = structNew();
    test["one"] = "a";
    test.two = "b";
    &lt;cfdump var=#test# /&gt;
    This will output as:
    one a
    TWO b
    As a result, I’ve gotten in the habit of using array notation whenever I’m setting a struct key, particularly if it’s in a CFC that may be used by Flash or another case-sensitive application.

  3. Jason Avatar

    Thanks for your followup – this is eons after the original post, but your comment helped me track down the solution to getting rid of the CF’s ridiculous auto-capping of var names.

Leave a Reply