<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx</link><description>One Web services interoperability issue that I have been investigating recently has to do with using null DateTime values between .NET and Java. Here's the problem: System.DateTime in the CLR is considered a value type, where as the equivalent in Java</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#128306</link><pubDate>Sat, 08 May 2004 04:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:128306</guid><dc:creator>Sean</dc:creator><description>public class Foo&lt;br&gt;{&lt;br&gt;   public Nullable&amp;lt;DateTime&amp;gt; Time { get; set; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;;)</description></item><item><title>re: WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#128308</link><pubDate>Sat, 08 May 2004 05:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:128308</guid><dc:creator>Sean</dc:creator><description>*bangs head on desk* Web Service!&lt;br&gt;&lt;br&gt;public class Foo : WebService&lt;br&gt;{&lt;br&gt;[WebMethod]&lt;br&gt;[return:XmlElement(&amp;quot;Time&amp;quot;, DataType=&amp;quot;time&amp;quot;)]&lt;br&gt;public Nullable&amp;lt;DateTime&amp;gt; Time { get; set; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;will it work?</description></item><item><title>re: WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#128430</link><pubDate>Sat, 08 May 2004 14:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:128430</guid><dc:creator>Beat Schwegler</dc:creator><description>Sean, according to Don's post will ASMX for whidbey support Nullable&amp;lt;T&amp;gt;&lt;br&gt;For more info: &lt;a target="_new" href="http://www.gotdotnet.com/team/dbox/default.aspx?key=2004-04-21T07:51:45Z"&gt;http://www.gotdotnet.com/team/dbox/default.aspx?key=2004-04-21T07:51:45Z&lt;/a&gt;&lt;br&gt;</description></item><item><title>re: WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#128657</link><pubDate>Sun, 09 May 2004 05:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:128657</guid><dc:creator>Sean</dc:creator><description>Good info, thanks.</description></item><item><title>WS Interoperability Tip of the Week. Null dates</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#129194</link><pubDate>Mon, 10 May 2004 20:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:129194</guid><dc:creator>Christopher Steen - Learning .NET</dc:creator><description>[ Via C# Items ]WS Interoperability Tip of the Week. Null dates. One&amp;amp;nbsp;Web services interoperability issue that I have been investigating&amp;amp;nbsp;recently&amp;amp;nbsp;has to do with using&amp;amp;nbsp;null DateTime values between .NET and Java.&amp;amp;nbsp; Here's the problem:System.DateTime&amp;amp;nbsp;in the CLR is considered a value...</description></item><item><title>re: WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#199229</link><pubDate>Wed, 28 Jul 2004 01:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:199229</guid><dc:creator>Dino Chiesa</dc:creator><description>I think this is an issue that the developer needs to be aware of, but if s/he follows good practices, there will be no terrible problems. &lt;br&gt;&lt;br&gt;Starting from a WSDL that specifies a field in a complexType as xsd:date, the .NET client-side proxy or server-side skeleton that is generated employs the (little-known?) feature in XML Serialization that: &lt;br&gt;  when you have a value-type property of name Xxxx&lt;br&gt;  and an additional field of name XxxxSpecified, which is a bool, and is decorated with [XmlIgnore]&lt;br&gt;&lt;br&gt;...then, the value of the bool indicates whether the value type is &amp;quot;null&amp;quot; or not. &lt;br&gt;&lt;br&gt;In other words, in case #1, you just set XxxSpecified to false, and you will send a &amp;quot;nil&amp;quot; xsd:date to your Java counterpart. &lt;br&gt;&lt;br&gt;In case #2, just check XxxSpecified for false before evaluating the value of the property. This works with any value type, including DateTime.  &lt;br&gt;&lt;br&gt;See &lt;a target="_new" href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp"&gt;http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp&lt;/a&gt;&lt;br&gt;for the doc on this (look for the discussion on propertyNameSpecified).&lt;br&gt;&lt;br&gt;</description></item><item><title>re: WS Interoperability Tip of the Week.  Null dates.</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#202219</link><pubDate>Fri, 30 Jul 2004 15:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:202219</guid><dc:creator>Dino Chiesa</dc:creator><description>Ahh, I think I have misunderstood the issue. &lt;br&gt;If the interface specifies minOccurs=1, then a null date will actually appear in the XML message as something like &amp;lt;Date xsi:nil='1'/&amp;gt;.  This is the thing that causes .NET to choke with a FormatException. &lt;br&gt;&lt;br&gt;You can mitigate the problem without changing the server interface or implementation - in other words just by doing some special handling on the client side. &lt;br&gt;&lt;br&gt;De-serialize as a string and set a hidden DateTime field behind it.  Eg, rather than&lt;br&gt;  public class MyType {&lt;br&gt;    public System.DateTime DateTimeField; &lt;br&gt;  }&lt;br&gt;&lt;br&gt;you can do: &lt;br&gt;&lt;br&gt;  public class MyType{&lt;br&gt;&lt;br&gt;    private static string formatString= &amp;quot;yyyy-MM-ddTHH:mm:ss.fffffffzzz&amp;quot;;&lt;br&gt;    private static System.Globalization.CultureInfo CInfo= new System.Globalization.CultureInfo(&amp;quot;en-US&amp;quot;, true);&lt;br&gt;&lt;br&gt;    [XmlIgnore] public System.DateTime  internal_DateTimeField;&lt;br&gt;    [XmlIgnore] public bool DateTimeFieldIsNull;&lt;br&gt;&lt;br&gt;    [XmlElement(IsNullable=true)]&lt;br&gt;    public string DateTimeField {&lt;br&gt;      set {&lt;br&gt;        if ((value!=null) &amp;amp;&amp;amp; (value != &amp;quot;&amp;quot;)) {&lt;br&gt;          internal_DateTimeField= System.DateTime.ParseExact(value, formatString, CInfo);&lt;br&gt;          DateTimeFieldIsNull= false; &lt;br&gt;        }&lt;br&gt;        else &lt;br&gt;          DateTimeFieldIsNull= true; &lt;br&gt;      }&lt;br&gt;      get {&lt;br&gt;        return (DateTimeFieldIsNull) ?&lt;br&gt;          null :&lt;br&gt;          internal_DateTimeField.ToString(formatString) ;&lt;br&gt;      }&lt;br&gt;    }&lt;br&gt;  }&lt;br&gt;&lt;br&gt;</description></item><item><title>Best-Practices-First Development, please!</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#675272</link><pubDate>Sun, 23 Jul 2006 04:20:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:675272</guid><dc:creator>António Cruz</dc:creator><description>Actualmente, existem v&amp;amp;#225;rias abordagens que podemos usar para desenvolver servi&amp;amp;#231;os. &lt;br&gt;Destacam-se duas:...</description></item><item><title>Best Practices-First Development</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#675317</link><pubDate>Sun, 23 Jul 2006 05:26:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:675317</guid><dc:creator>O Blog do Cruz</dc:creator><description /></item><item><title>Best Practices-First Development</title><link>http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx#682747</link><pubDate>Sat, 29 Jul 2006 23:06:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:682747</guid><dc:creator>António Cruz</dc:creator><description>Actualmente existem v&amp;amp;#225;rias abordagens que podemos usar para desenvolver servi&amp;amp;#231;os. Destacam-se duas:...</description></item></channel></rss>