Ryan McCauley
asked on
.NET Service Client DateTime Time Zone Offset Compatability Issue
I'm attempting to communicate with a Java webservice via a .NET application, using a Visual Studio Service reference (System.ServiceModel namespace classes). I've found that whenever it serializes a DateTime value it does not specify the offset. The problem is two fold:
I can't figure out how to create a DateTime object with a specific time zone. I can create a DateTimeOffset that will accomplish this, but the service client is expecting a DateTime object.
When the DateTime object is serialized, it does not include the time zone offset.
To elaborate on issue #2, the XML that the service expects for the timestamp object is as follows:
However, the XML that I see when tracing the .NET app is as follows:
The web service requires the time zone, because the underlying data is tracked in GMT-0. The data that is returned is in daily intervals, so if I don't specify a time zone then I get data back for GMT-0. Only when I provide the offset in the query do I get the in the data correct time zone.
I can't figure out how to create a DateTime object with a specific time zone. I can create a DateTimeOffset that will accomplish this, but the service client is expecting a DateTime object.
When the DateTime object is serialized, it does not include the time zone offset.
To elaborate on issue #2, the XML that the service expects for the timestamp object is as follows:
<startDate>2011-03-18T00:00:00-07:00</startDate>
<endDate>2011-03-19T00:00:00-07:00</endDate>
However, the XML that I see when tracing the .NET app is as follows:
<startDate>2011-03-18T00:00:00</startDate>
<endDate>2011-03-19T00:00:00</endDate>
The web service requires the time zone, because the underlying data is tracked in GMT-0. The data that is returned is in daily intervals, so if I don't specify a time zone then I get data back for GMT-0. Only when I provide the offset in the query do I get the in the data correct time zone.
http://www.15seconds.com/issue/020903.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.