?
Solved

.NET Service Client DateTime Time Zone Offset Compatability Issue

Posted on 2011-03-21
2
Medium Priority
?
1,622 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:Ryan McCauley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Expert Comment

by:Chad Smith
ID: 35184214
0
 
LVL 11

Accepted Solution

by:
lenordiste earned 2000 total points
ID: 35184519
You could try implementing a custom IClientMessageFormatter to alter the XML you are sending to the java service. This way you can still use a DateTime as forced by the java webservice API and programatically add timezone information on the fly before sending your request.

Here is a good read from a user who had the opposite problem you had (receiving timezone offset):
http://stackoverflow.com/questions/3067650/how-to-ignore-timezone-of-datetime-in-net-wcf-client

please note that he customizes the DeserializeReply method in order to strip timezone offset information while in your case you should work on the SerializeRequest method which he left intact.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question