DateTime XML Serialisation in .NET
Got quite a few posts to write about more version 1.1 to 2.0 migration issues. We've recently released the .Net 2 build onto some of our servers for testing, and there were quite a few problems. I'll try to keep 1 post per issue we saw.
We had a problem with our scheduled SMS service (which allows customers to specify a date and time when they want to submit a given SMS), in that the dates being used weren't being respected correctly when posting from a .Net 2 web service, through an XML formatted MSMQ, and being processed by a .Net 1.1 Windows service.
This was due to the differences between how the versions serialise DateTime objects to XML. There is what I would call a bug in the 1.1 framework that means you cannot serialise a DateTime that represents a UTC time (i.e. with zero offset from GMT, and no daylight savings adjustments). Check out this very useful article about DateTimes in general: Coding Best Practices Using DateTime in the .NET Framework.
It seems any time you put in is treated like the local time for the application deserialising it. I'm not entirely sure, but if you indicate that the time is in UTC (by adding a Z to the end of the time section), the 1.1 framework does treat that as UTC (Zulu) time, but then internally corrects it to the local time the server is in. That's certainly the behaviour we observed during tests anyway.
This has been fixed in version 2, so our solution to the problem just involves altering the order in which we deployed the .Net 2 builds to our servers.
No comments:
Post a Comment