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

标签 web-services delphi soap null delphi-xe2

我使用了一个包含数字元素的网络服务。 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/12645527/

相关文章:

delphi - 如何在 Windows 7 任务栏中隐藏应用程序?

delphi - 开放数组参数、类和字符串是否通过引用传递?

python - 如何处理pythonsoap模块zeep中的complexType参数?

web-services - 如何使用分页定义 REST API

ios - 从 UIAutomation 调用 webservice

windows - 为Firemonkey表单捕获最小化事件?

python - Suds + JIRA = SAXException

web-services - 如何导入 WSDL 文件以使用 MAVEN 开发 SOAP web 服务?

java - 接受列表作为使用多部分内容类型的 Jersey Web 服务的参数

javascript - 如何在 IE8 中上传文件(图像)(javascript 到 Web 服务)- 不使用 FileReader API,不使用 Apache Web 服务器(不使用 PHP)