我正在使用CFM2WDDX
在 CF11 中转换数组,但出现此错误:
Coldfusion.tagext.validation.WddxValidator$InvalidWddxPacketException: 无效的 WDDX 数据包..
我在这里使用此代码:
获取文件列表.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