0

I have a web site where I consume web services from other providers. I have imported the WSDL from the services and added them as Service References.

The problem occurs when the services sends DateTime parameters, cause .NET client automatically converts the received value to Local time. Ex: if the server in DE sends 08:00:00.000+02:00 the Azure web site will identify that as 06:00:00 Kind:Local, and since Azure websites work on UTC that is OK.

But I need the relative time of the DE server, since those are working hours, I can't store them as UTC. The problem is history data since UTC doesn't have DaylightSavingTime, and if you show historical time even when converting to client time in different part of the year it would be different time.

Also:

  • I can store current offset with the record which would be in UTC and this is one of the considered solutions. The offset I can get by calculating its current offset.
  • I can't get to string value since it is imported WSDL and automatic service reference (or can I)
  • I can't change reference because it causes a build error and wouldn't be good practice
  • I can't change the way server sends the data

If possible I would just like to get original time, like cutting off the timezone

Edit:
I can also make different deserializer if somebody know how to substitute default one for service deserialization.

Edit2:
Since generated code is partial classes, one of the best solutions would be to directly access the string of the field before deserialization. Is there a way to do that?

Edit3:
I have found that converting time from UTC converts in regards to DaylightSavings so it might just do the trick. But the original problem still remains.

var localDate = TimeZoneInfo.ConvertTime(utcDate,TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time"));
Goran Žuri
  • 1,623
  • 14
  • 24

0 Answers0