I am consuming a SAP-NetWeaver web-service. The response object contains a data and when it is not set it returns "0000-00-00". This leads to a deserialization error in my .NET 4.0 WCF proxy because the minimum valid date for .NET would be "0001-01-01".
I asked the SAP-developer to decorate the date element with the minoccurs="0" attribute and omit it if there's no value present but he states he can't do so.
Before I ask him to return "0001-01-01" for empty dates - just for my WCF proxy - I would like to know:
Is "0000-00-00" a valid date in terms of SOAP? Couldn't find it in any SOAP specification so please let me know your source of information.
Is there a way to tell the .NET deserializer to accept "0000-00-00" and handle it like DateTime.MinValue?
Many thanks!
UPDATE: Now the SAP-web-service returns an empty element if the date is null. But my problem remains the same.
there's a nice talk on this
here
it is possible to simply implement custom de serialisation of the class. so that the values of "0000-00-00" would be catched and converted into DateTime.MinValue. UPD: this is the code I've been talking about.
[OnDeserializing]
void OnDeserializing(StreamingContext c)
{
if (MyCustonObj == null)
{
MyCustonObj = new MyCustomClass();
MyCustonObj.MyStrData = "Overridden in deserializing";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With