All.
I realized what the cause is:
the wsdl2java generates the following constructor for the date object:
public DateOfBirth(java.lang.String value) {
try {
this.value = (java.text.DateFormat.getDateTimeInstance()).parse(value);
}
catch (java.text.ParseException e){
throw new java.lang.RuntimeException(e.toString());
}
}
This differs than what is used by the DateDeserializer.java to deserialize the values
from the xml instance document.
The work-around :
// Simple Types must have a String constructor
public Date(java.lang.String value) {
/**
try {
this.value = (java.text.DateFormat.getDateTimeInstance()).parse(value);
}
catch (java.text.ParseException e){
throw new java.lang.RuntimeException(e.toString());
}
**/
java.text.ParsePosition pos = new java.text.ParsePosition(0);
java.text.SimpleDateFormat sdf = new
java.text.SimpleDateFormat("yyyy-MM-dd");
this.value = sdf.parse(value, pos);
}
Can someone include this in the nightly builds?
thx.
--S.
-----Original Message-----
From: Ley, Selena (GMI/CPR Dev.) [mailto:[EMAIL PROTECTED]
Sent: Monday, August 11, 2003 3:06 PM
To: [EMAIL PROTECTED]
Subject: Date Deserialization Error
Hi.
I'm using the latest Axis 1.1 (nightly build for 8/10/2003). I see a lot of the
previous bugs from beta 2 version, which is great! many thanks!
My xml schema has the following element defined :
<xs:element name="DateOfBirth" type="DateOfBirth" />
<xs:simpleType name="DateOfBirth">
<xs:restriction base="xs:date" />
</xs:simpleType>
I am able to create use the wsdl2java to create the java beans. However, when I'm
testing with a sample message with the following snippet
<COPER_ENTITY:DateOfBirth>1975-08-06</COPER_ENTITY:DateOfBirth>
.. I receive the following error:
-------------------------------------
Reading Msg from Individual.xml
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "1975-08
-06"
at org.apache.axis.encoding.ser.SimpleDeserializer.onEndElement(SimpleDe
serializer.java:222)
at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl
.java:537)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(Deseri
alizationContextImpl.java:1083)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:204)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:845)
at org.apache.axis.message.MessageElement.getValueAsType(MessageElement.
java:698)
at org.apache.axis.message.MessageElement.getValueAsType(MessageElement.
java:678)
at com.ml.edsi.mif.tools.XmlToBeanDeserializer.deserializeXML(XMLToBeanD
eserializer.java:79)
at BeanDeserializerTester.main(BeanDeserializerTester.java:45)
MIFException: java.text.ParseException: Unparseable date: "1975-08-06"
I checked the DateDeserializer and the simpledateformat used to parse the date is
correct for this date.
thx.
--Selena