我从包含 nil="true"
的 Webservice 调用接收 xml:
<cacheEntry>
<systemFK nil="true"/>
</cacheEntry>
我使用 Flex DataService (webservice) 向导为 cacheEntry
组件创建服务对象。该对象稍后将在不同的 Web 服务调用中序列化并存储在数据库中。
我在服务对象中的 set SystemFK
方法上设置了一个断点。看来传入的值是一个空字符串!
允许该值为空字符串会导致另一端 Java 中的 webservice 实现出现问题。由于数据库值为 null,因此它期望返回 null,如果我避免设置此值,则 serviceObject 应该发送回 null,这将使数据库满意。
我的问题是:如何检测 XML 中是否存在 nil = true
以避免设置此值?
I am receiving xml from a webservice call that contains a nil="true"
:
<cacheEntry>
<systemFK nil="true"/>
</cacheEntry>
I used the Flex DataService (webservice) wizard to create the service objects for the cacheEntry
component. This object will be serialized later on a different webservice call and stored in a database.
I set a breakpoint on the set SystemFK
method in the service object. It appears that the value passed in was an empty string!
Allowing this value to be an empty string will cause problems in the webservice implementation in Java on the other side. Since the database value was null it is expecting a null in return, If I avoid setting this value, the serviceObject should send back a null which will make the database happy.
My question is: How can I detect that a nil = true
is present in the XML in order to avoid setting this value?
发布评论
评论(1)
由于某种原因,ActionScript XML 解析器不了解布尔值。如果没有看到为您生成的代码,我的猜测是您以某种方式得到了字符串
"true"
,而不是true
,这就是导致您的问题的原因。对访问器进行更改,就像
@nil
来自 XML 中的字符串一样,然后手动转换为布尔值。For some reason the ActionScript XML parsers don't know about Booleans. Without seeing the code that got generated for you, my guess is that somehow you're getting the string
"true"
, instead oftrue
, and that's what's causing your problem.Make changes to the accessors to act as if
@nil
comes from the XML as a string, and then convert to Boolean manually.