在soap ui中将空值传递到DateTime字段

17

我想在Soap UI中将DateTime字段传递为null值,一种选择是删除该标签。 还有其他方法可以在日期字段中传递null或其他值吗。

 <rt6:DateofBirth></rt6:DateofBirth>
4个回答

23

<rt6:DateofBirth></rt6:DateofBirth> 不是 null,但是是空字符串(在某些语言中不是这样),应该使用 xsi:nil="true",因此

<rt6:DateofBirth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

请记住,正如Ali Baraka建议的那样xsi命名空间可以在根标签级别上定义为xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",这使您可以从常规标记中删除它。


8
我必须使用xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"。我尝试了答案中提供的版本,但收到了验证错误。这是在SoapUI 4.6.4中发生的。 - David Dowdle
1
你确定你是使用 /> 而不是仅使用了 > 吗?也许你的模式不允许该字段为 null... - Betlista
似乎在Soap UI 5.2.1中无法工作 - 尽管在WSDL中我的DateTime字段标记为nillable =“true”,但我收到了错误消息“Attribute not allowed (no wildcards allowed): nil@http://w3.org/2001/....”。 - mutex
你能为此开一个新的问题吗?你应该分享你的XML,我相信问题会得到解决的;-) - Betlista
这告诉您在哪里放置命名空间http://blog.ginzburgconsulting.com/null-values-in-soap-requests/。 - infocyde

12

一般回答:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

将以下内容加入根标签的命名空间。然后将此属性添加到标签中。

xsi:nil="true"

E.g:

<vp1:DateofBirth xsi:nil="true"></vp1:DateofBirth>

2
以下方法适用于我:
<rt6:DateofBirth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

0

尝试传递一个高日期,如9999-12-31。这对我有用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接