By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,825 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,825 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 :

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.