Int64 类型的 Web 服务中的空白值 [英] Blank value in web service for Int64 type

查看:36
本文介绍了Int64 类型的 Web 服务中的空白值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一个包含数字元素的 Web 服务.Delphi wsdl 导入器将其设置为 Int64.

I consume a web service that has a numeric element. The Delphi wsdl importer sets it up as Int64.

Web 服务允许此元素为空.但是,因为它被定义为 Int64,所以当我在 Delphi 中使用 Web 服务而不为其设置值时,它默认为 0,因为它是一个 Int64.但我需要它为空,并且 Web 服务不接受 0 值(0 被定义为无效并由 Web 服务返回错误).

The web service allows this element to be blank. However, because it is defined as Int64, when I consume the web service in Delphi without setting a value for it, it defaults to 0 because it's an Int64. But I need it to be blank and the web service will not accept a value of 0 (0 is defined as invalid and returns an error by the web service).

如果类型是 Int64,我如何传递一个空值?

How can I pass a blank value if the type is Int64?

推荐答案

空龄(示例)

<E06_14></E06_14>

可能具有特殊含义,例如未知"年龄.

could have a special meaning, for example be "unknown" age.

在这种情况下,真正的问题是如何在 Delphi 端使字段为空.

In this case, the real question is how to make the field nillable on the Delphi side.

来自 J.M. Babet 的这篇博文:

From this post of J.M. Babet:

对nil"的支持一直是一个持续的问题.几种内置类型Delphi 不可为空.所以我们选择为这些情况使用一个类(不优雅,但它有效).因此,对于 Delphi 2007 的最新更新我添加了几个 TXSxxxx 类型来帮助解决这个问题.基本上:TXSBoolean, TXSInteger, TXSLong 等 TXSString 已经存在但是它没有注册.现在它是.导入 WSDL 时,您必须启用 Use 'TXSString for simple nillable types' 选项使导入器切换到 TXSxxxx 类型.在命令行上它是-0z+"选项.

Support for 'nil' has been an ongoing issue. Several built-in types of Delphi are not nullable. So we opted to use a class for these cases (not elegant but it works). So with the latest update for Delphi 2007 I have added several TXSxxxx types to help with this. Basically: TXSBoolean, TXSInteger, TXSLong, etc. TXSString was already there but it was not registered. Now it is. When importing a WSDL you must enable the Use 'TXSString for simple nillable types' option to make the importer switch to TXSxxxx types. On the command line it is the "-0z+" option.

用于导入 WSDL 向导的 DocWiki 还显示了与可空元素相关的两个选项:

The DocWiki for the Import WSDL Wizard also shows two options related to nillable elements:

  • 处理 nillable 和 optional 元素 - 选中此选项以使 WSDL 导入器生成有关 optional 的相关信息和可空属性.此信息由 SOAP 运行时使用允许某些属性为零.

  • Process nillable and optional elements - Check this option to make the WSDL importer generate relevant information about optional and nillable properties. This information is used by the SOAP runtime to allow certain properties be nil.

将 TXSString 用于简单的可空类型 - WSDL 标准允许简单类型为 nil,在 Delphi 或 NULL 中,在 C++ 中,而 Delphi和 C++ 不允许这样做.选中此选项以使 WSDL 导入器通过使用包装类的实例来克服这个限制.

Use TXSString for simple nillable types - The WSDL standard allows simple types to be nil, in Delphi or NULL, in C++, while Delphi and C++ do not allow that. Check this option to make the WSDL importer overcome this limitation by using instances of wrapper classes.

这篇关于Int64 类型的 Web 服务中的空白值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆