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

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

问题描述

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



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



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

解决方案

空白年龄(示例)

 < E06_14>< / E06_14> 

可能有一个特殊的含义,例如未知的年龄。



在这种情况下,真正的问题是如何在Delphi方面使字段无法使用。



From JM Babet的这篇文章


nil的支持一直是一个持续的问题。
Delphi的几种内置类型不可空。所以我们选择为这些案例使用一个类
(不优雅,但它有效)。所以随着Delphi 2007
的最新更新,我添加了几个TXSxxxx类型来帮助这个。基本上:
TXSBoolean,TXSInteger,TXSLong等。TXSString已经在那里,但
它没有注册。现在它是。导入WSDL时,您必须
启用使用'TXSString为简单的nillable类型'选项使
导入器切换到TXSxxxx类型。在命令行上是
-0z +选项。


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



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


  • 使用TXSString进行简单的nillable类型 - WSDL标准允许简单类型在Delphi或NULL,C ++中为零,而Delphi
    和C ++不允许这样做。检查此选项以使WSDL导入程序
    通过使用包装器类的实例来克服此限制。




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

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

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

解决方案

Empty age (example)

<E06_14></E06_14>

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

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

From this post of 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.

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

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

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

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