I want to create a web service that allows the caller to pass a DateTime to
the web service (that is, create a web method such as void
MyWebMethod(DateTime dt).) However, I want to be able to capture the
TimeZone of the caller as well - but I don't want the interface to specify an
xs:string as the method argument - I want it to use an xs:dateTime type
argument.
Now, I know when a DateTime structure is serialized into XML it becomes an
xs:dateTime type, and it is always formatted using the full ISO 8601 format,
including the offset to UTC for the sending computer (such as
"2005-08-24T01:02:03+08:00", where the offset to UTC is +8 hours in this
example.) When the web service receives the call, the xs:dateTime is
automagically deserialized back into a DateTime structure (probably by the
framework internally calling DateTime.Parse()), which converts the string
into the correct local time using the receiving computer's TimeZone.
Is there (with attributes?) to get at the raw string that comes in with the
method call, for a primative type such as DateTime? I know I could change
the param type to string, but I want to let the caller know that they should
only pass dateTimes, not arbitrary strings. I tried using
XmlElementAttribute to specify the argument use xs:dateTime with a .Net type
of System.String, but it gives me an error.
Any ideas? Thanks!