我的客户群终于不再使用 Coldfusion 8,所以现在我可以利用 Coldfusion 9Application.cfc -> onCFCRequest
事件。我有一个测试场景设置,但结果不是我所期望的。我有一个我调用的方法,它会产生一个有效的XML
像这样回应...
Response Header: Content-Type:application/xml;charset=UTF-8
Response:
<?xml version="1.0" encoding="UTF-8"?>
<rows><row id="10000282742505"><cell/><cell> ...
现在我介绍完之后onCFCRequest
事件我得到这个回来(这打破了我的网格)......
Response Header: Content-Type:application/xml;charset=UTF-8
Response:
<wddxPacket version='1.0'><header/><data><string><rows><row id="10000282742505"><cell></cell><cell> ...
这是事件...
<cffunction name="onCFCRequest" access="public" returntype="Any" output="true">
<cfargument type="string" name="cfc" required="true">
<cfargument type="string" name="method" required="true">
<cfargument type="struct" name="args" required="true">
<cfscript>
// OnCFCRequest security hole fix as detailed here: http://blog.adamcameron.me/2013/04/its-easy-to-create-security-hole-in.html
var o = createObject(ARGUMENTS.cfc);
var metadata = getMetadata(o[ARGUMENTS.method]);
if (structKeyExists(metadata, "access") && metadata.access == "remote"){
return invoke(o, ARGUMENTS.method, ARGUMENTS.args);
}else{
throw(type="InvalidMethodException", message="Invalid method called", detail="The method #method# does not exists or is inaccessible remotely");
}
</cfscript>
<cfreturn />
</cffunction>
如何让 onCFCRequest 以与远程函数返回相同的格式传递响应?
我知道这篇文章:http://www.bennadel.com/blog/1647-Learning-ColdFusion-9-Application-cfc-OnCFCRequest-Event-Handler-For-CFC-Requests.htm http://www.bennadel.com/blog/1647-Learning-ColdFusion-9-Application-cfc-OnCFCRequest-Event-Handler-For-CFC-Requests.htm
我可能最终会尝试这样做,但首先我想弄清楚为什么我不能简单地以相同的格式传递响应。