views:

2337

answers:

2

I am trying to pass some Subsonic collections to a client via a web service. When I reference the web service the IDE complains with:

Cannot serialize member 'EndDate' of type System.Nullable`1[System.DateTime]. XmlAttribute/XmlText cannot be used to encode complex types.

Is there any way of serializing nullable complex types in a .net web service?

+2  A: 

This is a .NET Limitation

If you want you can try generating your classes with this property in the SubSonicService section in the the web.config file.

generateNullableProperties="false"

http://forums.subsonicproject.com/forums/t/3285.aspx

Gulzar
Is this limitation still present in the .NET 3.5 ?
Manitra Andriamitondra
+2  A: 

The way you handle optional properties is to include a boolean XXXSpecified member where XXX is the name of the property. Nullable types are not handled properly by the xml serializer used by ASMX. Note that this is not a limitation of WCF.

jezell