Re: Axis <-> .Net xsd:date interoperability problem

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jabb (Jabb_at_discussions.microsoft.com)
Date: 07/28/04


Date: Wed, 28 Jul 2004 03:03:03 -0700

Dino, hi
Thanx alot for your answer.
As I understand, AXIS is able to read both lexical and canocical date representation, while the .NET platform preferes the lexical one. My question is could I do any system-scope definition (like registration of default format/serializer etc) and not an attributes adding (as you suggest) to wsdl.exe generated code - say, it is a considerable amount of existing written code I wouldn't like to change?
10x ahead,
Sincerely.
Jabb.

"Dino Chiesa [Microsoft]" wrote:

> > I try to call the Axis-based service from the .Net client and faced an
> interoperability problem for xsd:date type field.
> > Has somebody had such a problem? What are possible solutions?
>
> yes
>
> see
> http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlElementAttributeClassDataTypeTopic.asp
>
> for doc on how to control the serialization of a Date.
>
> You want to decorate the DateTime field with
> [XmlElement(DataType = "date")]
>
> which says "serialize this thing as an xsd:date.
> There are other options, though. You can use "time" and "dateTime" as well,
> for the corresponding W3C XML Schema types.
>
> ----
> The other issue you will run into is that in AXIS (and Java in general), a
> date can have a null value, while in .NET it cannot: System.DateTime is a
> value type. So you also need to handle the case where the date value is
> 'nil'.
>
> see http://blogs.msdn.com/smguest/archive/2004/05/07/128113.aspx for a
> summary.
>
> You can do this with a xxxSpecified field, typed with [XmlIgnore]. This is
> automatically generated if you start from WSDL, and generate your client
> classes from that.
>
> here's the doc
> http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp
>
> But be sure in your app code you check for XxxxSpecified before using the
> DateTime value. The DateTime value in .NET is only meaningful if
> XxxxSpecified is true, where Xxxx is the name of the property holding the
> DateTime.
>
> -Dino
>
> --
> Dino Chiesa
> Microsoft Developer Division
> d i n o c h @ OmitThis . m i c r o s o f t . c o m
>
> ps: maybe now you will ditch those Sun forums and come to a usable forum
> like the .NET newsgroups.
>
> ;)
>
>
> "Jabb" <Jabb@discussions.microsoft.com> wrote in message
> news:DC5BA1E6-E8FD-4210-A54C-3A75DA1B82F1@microsoft.com...
> > Good evening <whatever else> to all.
> > I'd like to repost to this forum message from Sun's JDC Forum :
> http://forum.java.sun.com/thread.jsp?forum=34&thread=541653
> > -----------------------------
> > Hi, people
> > I try to call the Axis-based service from the .Net client and faced an
> interoperability problem for xsd:date type field. It looks different for
> both platforms:
> > in .Net->Axis request:
> >
> > <beginDate>2004-07-27T18:07:32.5559555+03:00</beginDate>
> >
> > in Axis->.Net response:
> >
> > <beginDate>2004-07-27T15:07:36.007Z<beginDate>
> >
> >
> > As I see, Axis overcomes on the difference, but MS.NET - doesn't.. :( - I
> receive an exception:
> >
> > Exception: System.InvalidOperationException: There is an error in XML
> document (9, 86). --->
> > System.FormatException: String was not recognized as a valid DateTime.
> > at System.DateTimeParse.ParseExactMultiple(String s, String[] formats,
> DateTimeFormatInfo dtfi, DateTimeStyles style, DateTime& result)
> > at System.DateTime.ParseExact(String s, String[] formats,
> IFormatProvider provider, DateTimeStyles style)
> > at System.Xml.XmlConvert.ToDateTime(String s, String[] formats)
> > at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value,
> String[] formats)
> > at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value)
> > at System.Xml.Serialization.XmlSerializationReader.ToDateTime(String
> value) .... etc
> >
> >
> > Has somebody had such a problem? What are possible solutions?
> > Thanx ahead, I'll very appreciate any inputs.
> > Sincerely,
> > Jabb.
> > --------------------------
> >
> > Is the date serialization format a configuration issue of .Net platform?
> > Greatly appreciate any inputs
> > Jabb.
> >
>
>
>



Relevant Pages