ColdFusion 如何序列化从 Web 服务调用返回的变量?

发布于 2024-09-09 05:04:33 字数 760 浏览 1 评论 0原文

我想知道 ColdFusion 如何序列化从 Web 服务调用返回的变量,以便我可以计算出它们有多大(以字节为单位)。

我遇到了一些问题,当我的一些 Web 请求返回时(我可以从日志语句中看出),但随后我收到调用错误:无法执行 Web 服务调用。

我从调试中得到的预感到目前为止所做的事情是,它尝试序列化并发回的返回结构太大,我想为其大小添加另一个日志语句。我可以在返回之前在远程方法中记录 len(resultStruct)len(serializeJSON(resultStruct)) ,但理想情况下我会得到我们发回的真实长度在一系列管子上。

发出请求的代码(取自运行我们的功能测试的组件:-P)如下:

<cfinvoke webservice="#remoteFacadeURL#" method="executeTestCase" returnvariable="currMethodResult">
    <cfinvokeargument name="componentName" value="#componentName#"/>
    <cfinvokeargument name="methodNames" value="#getTestsQuery.methodName#"/>
    <cfinvokeargument name="TestRunKey" value="#TestRunKey#"/>
</cfinvoke>

I would like to know how ColdFusion serializes variables returned from web service calls so that I can figure out how large (in bytes) they are.

I am having issues where when a few of my web requests are returning (I can tell from log statements) but then I get INVOCATION ERROR: Cannot perform web service invocation.

My hunch from the debugging I've done thus far is that the return struct it is trying to serialize and send back is too large, and I would like to add another log statement for its size. I could log len(resultStruct) or len(serializeJSON(resultStruct)) in the remote method right before returning, but ideally I'd have the true length we are sending back over the series of tubes.

The code (taken from a component that runs our functional tests :-P ) that makes the request is as follows:

<cfinvoke webservice="#remoteFacadeURL#" method="executeTestCase" returnvariable="currMethodResult">
    <cfinvokeargument name="componentName" value="#componentName#"/>
    <cfinvokeargument name="methodNames" value="#getTestsQuery.methodName#"/>
    <cfinvokeargument name="TestRunKey" value="#TestRunKey#"/>
</cfinvoke>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-09-16 05:04:33

我通过检查响应找到了答案,这让我找到了相应的文档,该文档表明序列化类型取决于 cffunction 标记的“returnFormat”属性,如果缺少该属性,则默认为 WDDX。

来自 cffunction ColdFusion 8 文档

默认情况下,ColdFusion 序列化所有
返回类型(包括简单返回
类型)(XML 除外)转换为 WDDX 格式,
并将 XML 数据作为 XML 文本返回。

您还可以使用 returnformat 作为
调用时的HTTP请求参数
远程CFC功能。这个参数
具有相同的效果
returnformat 属性和覆盖
任何 returnformat 属性值
在 cffunction 标记中指定。

其他非默认选项是纯文本(可以转换为字符串的类型的文本)和 json。

I found the answer by inspecting the response and that let me to the appropriate documentation which indicates that the serialization type depends on the "returnFormat" attribute of the cffunction tag, which if missing defaults to WDDX.

Fromt the cffunction ColdFusion 8 Documentation:

By default, ColdFusion serializes all
return types (including simple return
types), except XML, into WDDX format,
and returns XML data as XML text.

You can also use returnformat as an
HTTP request parameter when calling a
remote CFC function. This parameter
has the same effect as the
returnformat attribute and overrides
any returnformat attribute value
specified in the cffunction tag.

The other, non-default, options are plain (text for type that can be converted to a string) and json.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文