Web服务允许此元素为空.但是,因为它被定义为Int64,当我在Delphi中使用Web服务而不为其设置值时,它默认为0,因为它是Int64.但我需要它为空,Web服务不接受值0(0被定义为无效并由Web服务返回错误).
如果类型是Int64,我如何传递空值?
解决方法
<E06_14></E06_14>
可能有特殊意义,例如“未知”年龄.
在这种情况下,真正的问题是如何使字段在Delphi端可用.
从J.M. Babet的this post开始:
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.