Link to home
Start Free TrialLog in
Avatar of Ryan McCauley
Ryan McCauleyFlag for United States of America

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:

<startDate>2011-03-18T00:00:00-07:00</startDate>
<endDate>2011-03-19T00:00:00-07:00</endDate>

Open in new window


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>

Open in new window


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.
Avatar of Chad Smith
Chad Smith
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of lenordiste
lenordiste
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial