gpt4 book ai didi

web-services - Int64 类型的 Web 服务中的空白值

转载 作者:行者123 更新时间:2023-12-03 14:47:54 24 4
gpt4 key购买 nike

我使用具有数字元素的 Web 服务。 Delphi wsdl 导入器将其设置为 Int64。

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

如果类型是 Int64,如何传递空白值?

最佳答案

空年龄(示例)

<E06_14></E06_14>

可能有特殊含义,例如“未知”年龄。

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

来自this post J.M. Babet 的:

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.

DocWiki for the Import WSDL Wizard还显示了与可为空元素相关的两个选项:

  • 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.

  • 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.

关于web-services - Int64 类型的 Web 服务中的空白值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12434202/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com