This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > September 2004 > IsNullable may not be 'true' for value type System.Int64





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author IsNullable may not be 'true' for value type System.Int64
Luis Duarte

2004-09-22, 11:21 am

I have a problem in a element from a Web Service that the
type is a long. The Wsdl especifield for this particular
field is like this:
"
<element maxOccurs="1" minOccurs="0" name="REFWF"
nillable="true" type="xsd:long"/>
"

The generated code from the wsdl.exe is like this:
"
public long REFWF;

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool REFWFSpecified;
"

But, this element must handle nullable values but nothing
is done in the generated code. So if a XML is
deserializeble with the tag:

"
<REFWF xsi:nil="true"/>
"

The cient program gives the following error:

"There is an error in XML document (145, 7)."
System.Exception
[System.InvalidOperationException]
{System.InvalidOperationException}
System.InvalidOperationException
at System.Int64.Parse(String s, NumberStyles style,
IFormatProvider provider)
at System.Xml.XmlConvert.ToInt64(String s)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializat
ionReader1.Read21_ConteudoSRVC49Out4_5(Boolean isNullable,
Boolean checkType)
.....
"

To resolve this I tried to force the generated code to
accept nulls like this:

"
[System.Xml.Serialization.XmlElementAttribute
(IsNullable=true)]
public long REFWF;

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool REFWFSpecified;
"

But at Runtime the client program gives me the following
Exception:

"
There was an error reflecting
type 'WEB_SERVICE_SRVC49.isqua.mensagemOut4_5'." }
System.Exception
+ [System.InvalidOperationException]
System.Reflection.MethodBase
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMa
pping(TypeModel model, String ns, ImportContext context,
String dataType, Boolean repeats)
System.Xml.Serialization.XmlSerializer..ctor(Type type,
String defaultNamespace)
.....
"

Is this a limitation problem from the framework or is it a
Bug, because if the element is a string no error is found
and everything runs OK.
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews