I have this in some WSDL:
<element name="startDate" type="xsd:dateTime"/> <element name="endDate" type="xsd:dateTime"/>
Which results in the following text in the SOAP envelope:
<startDate>2008-10-29T12:01:05</startDate> <endDate>2008-10-29T12:38:59.65625-04:00</endDate>
Only some times have the milliseconds and zone offset. This causes me a headache because I’m trying to get a range of 37 minutes and 54 seconds in this example, but because of the offset I end up with 4 hours, 37 minutes, 54.65625 seconds. Is this some kind of rounding error in DateTime? How do I prevent this from happening?
I suspect your endDate value has the Kind property set to DateTimeKind.Local.
You can change this to DateTimeKind.Unspecified as follows:
after which I believe it will be serialized without the timezone offset.
Note that you will get a DateTime with DateTimeKind.Local if you have initialized it using DateTime.Now or DateTime.Today, and DateTimeKind.Utc if you have initialized it using Datetime.UtcNow.