Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Raymond Camden / Raymond Camden (Raymond Camden)
Created: 12/03/2012
Components: REST Services
Versions: 10.0
Failure Type:
Found In Build/Fixed In Build: Final / 287253
Priority/Frequency: Normal / Few users will encounter
Locale/System: English / Windows 7 64-bit
Vote Count: 0
I'm using restSetResponse to return a custom XML string. Ie, I don't want the built in XML serialization. This worked fine:
remote void function sayHelloEvening() httpMethod="get" restPath="/custom" {
var result = {};
result.status=201;
result.content = "<person><name>#variables.data.name#</name><age>#variables.data.age#</age><likes>";
for(var i=1; i<arrayLen(variables.data.likes); i++) {
result.content &= "<like>#variables.data.likes[i]#</like>";
}
result.content &= "</likes></person>";
restSetResponse(result);
}
But I noticed that the browser didn't recognize that it was XML. I remembered that I could set a header:
result.headers["content-type"] = "application/xml";
And as soon as I did this, I got this error in the Application log:
"Error","ajp-bio-8012-exec-1","12/03/12","09:57:31","RestPreso","java.lang.String cannot be cast to javax.ws.rs.core.MediaType The specific sequence of files included or processed is: C:\websites\webroot\restpreso\services\custom.cfc'' "
It appears as if CF is assuming I've got an XML object. But CF should not assume that. My result is a string, not an XML variable. CF shouldn't even care what I return. If I say I'm returning XML let me worry about it being valid XML.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3376486
External Customer Info:
External Company:
External Customer Name: cfjedimaster
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: