从CF10迁移至CF2016后,如何避免SOAP类型强制转为小写?
This is a known behavior shift between ColdFusion 10 and ColdFusion 2016 when working with web services that return components. Let’s break down what’s happening and how to fix it:
Why This Change Occurs
In ColdFusion 10, when you set returntype="components" for a web service, the platform kept the camel-casing of your component properties intact in both the WSDL and response XML. But ColdFusion 2016 updated its default behavior—now it converts all complex return type property names to lowercase. This is likely tied to upgrades to the underlying Axis2 web service engine that ColdFusion uses, which changed its default naming strategy.
Solutions to Restore Camel-Casing
You have two solid options to fix this, depending on whether you need a targeted or global fix:
Component-Level Annotation (Recommended for Specific Services)
Use thexmlnameattribute in your component properties to explicitly define the exact casing you want in XML output. This overrides ColdFusion’s default lowercase conversion. Example:component { // Explicitly map property to camel-cased XML element property name="userName" type="string" xmlname="userName"; property name="accountId" type="numeric" xmlname="accountId"; remote function getUserDetails() returnType="components" { var user = new UserComponent(); user.userName = "janeSmith"; user.accountId = 67890; return user; } }This ensures the response XML and WSDL will use
userNameandaccountIdinstead of the lowercase variants.Global ColdFusion Admin Setting (For Wide-Scale Reversion)
If you want all your web services to behave like they did in CF10, adjust a setting in the ColdFusion Administrator:- Go to Web Services > Settings
- Look for the option labeled "Element Naming Strategy" or "Property Casing" (exact wording may vary by CF2016 update version)
- Switch the setting from "Lowercase" to "Preserve Original" (or similar)
- Restart the ColdFusion server to apply changes
Note: This is a global change, so test it thoroughly to avoid breaking services that might rely on the new lowercase behavior.
Migration Testing Takeaway
Since this issue slipped past initial testing, it’s a good idea to add validation of web service output structure (including element casing) to your migration test plan. Tools like SOAPUI can help you compare WSDLs and response XMLs between CF10 and CF2016 to catch these subtle shifts early.
内容的提问来源于stack exchange,提问作者Dan Roberts

