8

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?

2
  • Tell the service provider that they should fix their service? A blank is not a valid value for an Int64 (and using an Int64 for a person's age is pretty ridiculous in the first place - not many people live longer than what a byte can hold, at least since Biblical times).
    – Ken White
    Sep 15, 2012 at 5:07
  • Maybe you can try 999 as the age
    – Hendra
    Sep 15, 2012 at 5:25

1 Answer 1

8

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.

2
  • I tried that option but the wsdl importer still imports it as Int64. There must be something in the wsdl telling the importer that it's not nilable. I tried changing the imported unit definition for E06_14 to TXSInteger but couldn't find a way to make TXSInteger a nil value. Maybe I'll try changing it to TXSString and see if I have better luck.
    – Sam M
    Sep 15, 2012 at 18:34
  • 3
    I modified the imported unit and changed the type from Int64 to TXSInteger. Then, I set it to nil instead of instantiating TXSInteger. Works great now.
    – Sam M
    Sep 18, 2012 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.