Closed JamoCA closed 2 years ago
Seems reasonable enough to me. I'll test it soon and add long as it doesn't break anything else, it should be merged.
I discovered this as I was troubleshooting a reported Twilio endpoint error. I initially used the anythingToXml example and only the response headers (no body) were displaying in the dashboard. This routine tests for XML (using jQuery) and, if valid, performs the necessary entity string replacements so it can be rendered as HTML.
BTW, I wasn't able to quickly verify Twilio's "Accept" request header, but they require the response to be in XML format. The anythingToXml library wasn't generating the XML string that they were expecting, so I manually generated it and then updated the serializer to echo variables.data
if it is already an XML string. (This approach also prevents double-encoding.)
// customSerializer.cfc
<cffunction name="getAsXML" taffy:mime="application/xml;text/xml" output="false" hint="Returns string 'as is' if already valid XML.">
<cfif isSimpleValue(variables.data) and isXml(variables.data)>
<cfreturn javacast("string", variables.data) />
<cfelse>
<cfreturn vairables.anythingToXml.toXml(variables.data) />
</cfif>
</cffunction>
Added support for XML response rendering in the dashboard by using HTML entities. (XML API responses weren't rendered. They were visible in F12 DevTools console, but not on the dashboard.)