【发布时间】:2015-03-31 16:45:58
【问题描述】:
我正在使用CFM2WDDX 转换 CF11 中的数组,但出现此错误:
coldfusion.tagext.validation.WddxValidator$InvalidWddxPacketException: WDDX 数据包无效..
我在这里使用此代码:
getFileList.cfm
<cfsetting enablecfoutputonly="Yes">
<cfset thisdir = ExpandPath(".\")>
<cfdirectory directory="#thisdir#" action="LIST" name="imagefiles" recurse="No">
<cfscript>
// get .gif|.jpg|.png files from the cfdirectory query...
numRows = imagefiles.recordcount;
imageFileArray = ArrayNew(1);
for (row = 1; row LTE numRows; row++) {
if (refindnocase("(.gif|.jpg|.png)",imagefiles.name[row]) neq 0) {
ArrayAppend(imageFileArray, imagefiles.name[row]);
}
}
</cfscript>
<cfwddx action="cfml2wddx" input=#imageFileArray# output="wddxText">
<cfoutput>#wddxText#</cfoutput>
正如您所看到的,代码创建了一个图像名称数组,然后我通过 cfhttp 访问这些图像名称来执行我需要的任何操作。我在 CF9 服务器上有完全相同的代码和完全相同的目录内容,并且正在正常工作,但在 CF11 中我遇到了格式错误。这个功能在 CF11 中是否有所改变?
这是我用来访问上述代码的代码:
<cfhttp url="http://example.com/images/ClientLogos/getFileList.cfm" method="GET" timeout="10" throwonerror="Yes">
<cfwddx action="WDDX2CFML" input="#trim(cfhttp.filecontent)#" output="imageArray" validate="true">
<cfreturn imageArray>
getFileList.cfm 与图像位于同一目录中,因此它在调用的本地服务器上执行。 (这就是为什么我认为 CF11 可能是问题所在)
CF9 的部分输出:
以及来自 CF11 的部分输出:
CF 11 中的 CFHTTP.Header:
HTTP/1.1 200 OK Content-Type: text/html;charset=UTF-8 Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET Access-Control-Allow-Origin: * Date: Tue, 31 Mar 2015 18:50:35 GMT Connection: close Content-Length: 10807
CF 9 中的 CFHTTP.Header:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8 Vary: Accept-Encoding Server: Microsoft-IIS/7.5 X-Powered-By: ASP.NET Date: Tue, 31 Mar 2015 18:51:20 GMT Connection: close
【问题讨论】:
-
@Henry 你是说我应该将它添加到错误库中还是从类似问题中搜索它?
-
如果您只是浏览到
getFileList.cfm页面,它会以 WDDX 格式显示数据吗?我刚刚在本地 CF9 和 CF11 服务器上做了一个快速测试。两者都按预期工作。但是,我没有执行cfhttp部分。我刚刚浏览到我的测试页面。 -
@Geo 如果您有可重现的意外情况,请在此处提交错误报告。
-
CF9 的部分输出: 澄清一下,您是否真的对两个
filecontent值进行比较以验证字符串是否真实 i> 相同(不只是看起来相同)并且还比较 cfhttp 标头?完整的堆栈跟踪是否提供了有关数据包问题的任何其他详细信息,还是只是样板文件?
标签: coldfusion coldfusion-9 cfml coldfusion-11 wddx