How to serialize a DateTime with a null value in a .net web service?

I am trying to pass some subzone collections to a client through a web service. When I refer to the web service, the IDE complains about:

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

Is there a way to serialize nullable complex types in a .net web service?

+3
source share
2 answers

The way to handle optional properties is to include the XXXSpecified logic element, where XXX is the name of the property. Optional types are not handled correctly using the XML serializer used by ASMX. Please note that this is not a limitation of WCF.

+3

.NET

, SubSonicService web.config.

generateNullableProperties = ""

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

+2

Source: https://habr.com/ru/post/1698321/


All Articles