@ doc_180有正确的概念,除了他专注于数字,而原始海报有字符串的问题.
解决方案是更改mx.rpc.xml.XMLEncoder
文件.这是第121行
if (content != null)
result += content;
[我查看了Flex 4.5.1 SDK; 行号可能在其他版本中有所不同]
基本上,验证失败是因为'content为null',因此您的参数不会添加到传出的SOAP数据包中; 从而导致缺少参数错误.
您必须扩展此类以删除验证.然后链上有一个大雪球,修改SOAPEncoder以使用修改后的XMLEncoder,然后修改Operation以使用修改后的SOAPEncoder,然后对WebService进行moidfying以使用备用Operation类.
我花了几个小时,但需要继续前进.这可能需要一两天时间.
您可以修复XMLEncoder行并进行一些猴子修补以使用您自己的类.
我还要补充一点,如果你切换到使用带有ColdFusion的RemoteObject/AMF,则传递null并没有问题.
11/16/2013更新:
我最近添加了一篇关于RemoteObject/AMF的评论.如果您使用的是CF10; 然后从服务器端对象中删除对象上具有空值的属性.因此,您必须在访问之前检查属性是否存在,否则您将收到运行时错误.像这样检查:
这是CF9的行为变化; 其中null属性将变为空字符串.
编辑12/6/2013
由于存在关于如何处理空值的问题,因此这是一个快速示例应用程序,用于演示字符串"null"如何与保留字null相关联.
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" min min initialize="application1_initializeHandler(event)">
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
var s :String = "null";
if(s != null){
trace('null string is not equal to null reserved word using the != condition');
} else {
trace('null string is equal to null reserved word using the != condition');
}
if(s == null){
trace('null string is equal to null reserved word using the == condition');
} else {
trace('null string is not equal to null reserved word using the == condition');
}
if(s === null){
trace('null string is equal to null reserved word using the === condition');
} else {
trace('null string is not equal to null reserved word using the === condition');
}
}
]]>
跟踪输出是:
使用==条件,null string不等于null保留字
使用===条件,null string不等于null保留字
@ Reboog711员工的姓氏实际上是字符串"Null",如"我的名字是Pat Null"你的答案未能通过员工的姓氏.你回答的只是隐藏了这样一个事实:"Null"被Ben Burns所描述的appendChild()方法强制转换为null的语言概念.结果仍然是系统未能与Null先生或Null女士打交道.
别担心.如果你想看到真正的问题,请添加`var xml:XML = null root>; var s:String =(xml == null)?"wtf?xml强制为null?!!" :"xml没有强制为null."; trace(s);`到您的代码示例.
@MaxxDaymon我认为您误解了我的答案实际上是什么。它没有提出解决方案。而是解释问题发生的原因;并引用Flex框架中的相关代码。我最近的编辑可能放错了位置;因为它讨论了另一种方法,并且与原始问题没有直接关系。