Board index » delphi » null integer is not handled in response

null integer is not handled in response

2007-09-18 09:06:26 PM
I'm using TD2006 with the latest Delphi SOAP Runtime and Importer Update
I have a WSDL with the following complex type:
<complexType name="contentInfo">
<element maxOccurs="1" minOccurs="0" name="activateMaxWatchdog"
nillable="true" type="xsd:unsignedInt"/>
The updated WSDLImp.exe generates this class for me:
contentInfo = class(TRemotable)
FactivateMaxWatchdog: Cardinal;
FactivateMaxWatchdog_Specified: boolean;
procedure SetactivateMaxWatchdog(Index: Integer;
const ACardinal: Cardinal);
function activateMaxWatchdog_Specified(Index: Integer): boolean;
property activateMaxWatchdog: Cardinal Index (IS_OPTN or IS_NLBL)
read FactivateMaxWatchdog write SetactivateMaxWatchdog
stored activateMaxWatchdog_Specified;
So far I am glad to see that now the nillable attribute is considered
with the IS_NLBL constant in the property's index specifier, but I can't
see how this informaton is utilized at runtime.
Hence the following response isn't deserialized correct und I get a
EConvertError when it comes to converting the empty value in an integer.
<?xml version="1.0"?>
<activateMaxWatchdog xsi:nil="true"/>
I can workaround the error by changing the type of activateMaxWatchdog
to variant, but my question is: Is this an error in the WSDLImp.exe or
the SOAP runtime or do I something wrong?
Thanks, Stephan

Re:null integer is not handled in response

Hello Stephan,
I believe there's a thread about this issue somewhere (maybe google has it
First off, it is something that we addressed in a subsequent patch (i.e.
after D2007). I just have not had the time to merge the patch changes to the
runtime/importer posted on CodeCentral. This is something that keeps getting
pushed out as other higher tasks pop up.
The fix works in two ways:
#1. There's a "runtime only" change. For this change, the importer stays
with a built-in Delphi type (such as 'Integer', 'String', 'Double', etc) and
the runtime simply assigns a default value (0, or '') when deserializing
null. The advantage is that you work with the simpler intrinsic type but you
cannot distinguish between '0' (or '') and null when receiving one and you
cannot *send* null.
#2. There's also an "importer + runtime" change. For this one, the importer
maps the Delphi type to one of the TXSxxxx type: such as TXSString,
TXSBoolean, TXSLong, etc). These are class wrappers of the intrinsic types.
They are a little less convenient to work with (you need to manage the
instances) but you can distinguish between an empty string/zero value vs.
null. The -oZ+ option enables this (Use TXSType for Simple Nillable XML
types) feature with the latest importer.
As I can not tell when I will have time to merge the latest patch updates into
CodeCentral, I will offer to make the latest importer and runtime available
via email. If you'd like to do that, please contact me at bbabet @ borland
dot com.
Let me know if I can provider more information.

Re:null integer is not handled in response

Hello Stephan,
After posting the prior reply, I googled for 'TXSString' and found some
threads on this issue. Some of the threads were before we released the
patches for Delphi 2007 so they don't cover the fact that we've added several new
TXSxxxx wrappers and the -oZ+ option to trigger the importer.
Reading the threads I also remembered that nillable enumerations are not
properly handled currently. Ideally we would do something equivalent to .NET
System.Nullable<EnumerationType>. But since that would only work with
versions of Delphi with generic support, a importer fix (whereby we generate
a class wrapper around the enumeration) seems like a better approach.
Look at threads 'nil value for integer' and ' Serializing Integer values
when nillable="true"'