Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank value in web service for Int64 type

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?

like image 267
Sam M Avatar asked Sep 15 '12 03:09

Sam M


1 Answers

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.

like image 159
mjn Avatar answered Nov 07 '22 09:11

mjn