You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Armstrong, Jason" <JA...@MSA.com> on 2003/06/05 17:20:40 UTC

RE: .NET and Apache Axis interop issue with xsd:date and xsd:date Time

Stephanie,

I tried your recommendation and the classes that were generated already had
that information.  However, I was able to go into the class that was
generated by .NET and changed it's metadata attribute to date and it solved
my issue.  Thanks for your assistance!

Old Code in C# Generated Class:
        /// <remarks/>
 
[System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSc
hemaForm.Unqualified, DataType="dateTime")]
        public System.DateTime week;

New Code in C# Generated Class:
        /// <remarks/>
 
[System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSc
hemaForm.Unqualified, DataType="date")]
        public System.DateTime week;

Jason S. Armstrong
Applications Manager | Management Science Associates, Inc.

-----Original Message-----
From: Kroll, Stephanie [mailto:SKroll@gers.com]
Sent: Wednesday, June 04, 2003 12:49 PM
To: axis-user@ws.apache.org
Subject: RE: .NET and Apache Axis interop issue with xsd:date and
xsd:dateTime


What you need to do is to add Axis type metadata to the bean being
serialized that contains the Date property.  Type metadata is added to the
generated classes when you run WSDL2Java.  The metadata is read by Axis at
runtime and used in the serialization process.  This feature is almost
totally undocumented in the Axis documentation.

If you run WSDL2Java on the AddressBook sample, you'll see that you get an
Address class generated with some static methods and a static initializer
that declare the XML types for the bean's properties.

In your case, if you add the static type description methods to your bean
and set the XmlType of the Date property to an xsd:date, like below, then
Axis will only return the date portion and drop the time.
elemField.setXmlType(new QName("http://www.w3.org/2001/XMLSchema", "date"));

Stephanie

-----Original Message-----
From: Armstrong, Jason [mailto:JArmstrong@MSA.com]
Sent: Wednesday, June 04, 2003 9:12 AM
To: 'axis-user@ws.apache.org'
Subject: .NET and Apache Axis interop issue with xsd:date and
xsd:dateTime


All,

I have an Apache Axis web service using document/literal encoding that
returns an object hierarchy (using the bean serializer/deserializer), one of
the attributes on this field is declared as an xsd:date (I also tried
xsd:dateTime).  The web service client is an .NET application.  The problem
I am having is that too much information is being sent back to the client
when the java.util.Date or java.util.Calendar object is being serialized.
In this particular case the value '2003-08-15T18:35:22.981Z' is being
returned.  In this particular web service I need to only send the date
portion back e.g. '2003-08-15'  Any recommendations?

Additionally, I do have requirements for other web services to be able to
include dates and times together, so I also need to be able to include a
date/time string that .NET can successfully parse.  Right now, I'm cheating
and sending the values back as xsd:string, but I'd like to be able to use a
more accurate type declaration.  I've thought about writing a custom
serializer/deserializer for xsd:date and xsd:dateTime, but I don't have any
great desire to reinvent the wheel if it's already been done.  Any advice
and recommendations would be appreciated.

Thanks in advance for any and all help!

Jason S. Armstrong
Applications Manager | Management Science Associates, Inc.
jarmstrong@msa.com