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

标签 web-services delphi soap null delphi-xe2

我使用具有数字元素的 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/

相关文章:

web-services - 聚合来自 Windows Azure 中不同 Web 服务的并行结果

delphi - 输入框中的取消按钮未关闭

java - 使用 WSS4J/camel cxf (Https) 进行基本身份验证

java - 解码错误: unexpected element from legacy request with legacy WSDL

web-services - 在单个 WSDL 文件中定义多个服务是什么意思

java - android调用API后如何返回值(每次调用函数并返回值)?

java - WSDL 的问题

python - Python可以调用DLL中的Delphi函数吗?

delphi - 动态创建组件时如何强制VCL样式覆盖?

java - 使用 JAX-RS/Jersey 绕过 JAX-WS SOAP 开销?