【问题标题】:How to pass Null in SOAP?如何在 SOAP 中传递 Null?
【发布时间】:2012-12-22 09:26:09
【问题描述】:

我的 WCF Web 服务中有以下方法签名:

public CreateItemResult CreateAgent(int tenantId, string loginName, int timeZoneId)  

如何在我的 SOAP 中为 timeZoneId 传递 Null 值?我尝试在我的 SOAP 请求中传递以下内容,但没有成功:

<timeZoneId i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />  

我必须在我的 WCF Web 服务中将 int timeZoneId 更改为 int? timeZoneId 才能将 Null 值传递给它吗?还有其他方法吗?
谢谢!

【问题讨论】:

  • 当您尝试通过null timeZoneId 时发生了什么?也许检查为您的服务生成的架构。如果 minOccurs 为 0,那么您应该可以完全省略该元素。如果您没有看到它,minOccurs 默认为 1。查看使 timeZoneId 可以为空是否会更改架构。

标签: javascript ajax wcf soap null


【解决方案1】:

是的,如果你想传递 null,你需要让你的操作合约中的 timeZoneId 可以为 null (int?)。否则,timeZoneId 元素在 XSD 架构中被视为不可空。

【讨论】:

    猜你喜欢
    • 2019-04-27
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 2018-01-09
    相关资源
    最近更新 更多