By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Solution : How to handle null values (especially date time) in a c# web service

P: n/a
Here is another programming blog entry. Sorry for the normal friends :)

I recently ran into a problem with a web service I was trying to call
from c# where the web service returned null dates (and other null
values on elements that end up de-serialized as value types)

I didn't find any good solutions online (other than wait for nullable
types in c# 2.0 or change the service, neither of which was applicable
in my situation)

I ended up working out a solution with microsoft, and here it is. The
following class will loop through a returned soap call, and set any
datetime fields that are null to be DateTime.MinDate

This can easily be extended to enable any other fields that need
default values (enums, etc)
This solution uses reflection, SoapExtension, SoapExtensionAttribute,
etc to solve the problem. A complete example can be found on my blog :
http://geekswithblogs.net/gaijin42/a.../18/57332.aspx

Nov 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.