axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 25012] - dateTime not parsed properly in the SOAP message
Date Fri, 02 Jan 2004 10:05:12 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25012>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25012

dateTime not parsed properly in the SOAP message

rahul.karwa@patni.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |



------- Additional Comments From rahul.karwa@patni.com  2004-01-02 10:05 -------
I tried with the same example posted by Zenosh with axis 1.1. Latest CVS 
generates the proper SOAP request (<orderDate>2003-11-
20T08:26:00.940Z</orderDate>) but it throws Exception like
"java.lang.RuntimeException: java.text.ParseException: Unparseable date:2003-11-
20T08:26:00.940Z"

The exception is generated at the following line 
java.util.Date dt = (java.text.DateFormat.getDateTimeInstance()).parse(value);

Since the date pattern is not specified in DateFormat instance it throws 
exception.

When we replace the above line to this
java.util.Date dt = ((java.text.DateFormat) new java.text.SimpleDateFormat
("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")).parse(value);
it works fine.


To generate the proper java file with above changes from WSDL2Java command we 
need to change org.apache.axis.wsdl.toJava.JavaBeanWriter.java file of axis 1.1.

protected void writeSimpleConstructors() {

//-------------
                else if (simpleValueType.equals("java.util.Date")) {
                  pw.println("        try {");
                  pw.println("            this.value = 
(java.text.DateFormat.getDateTimeInstance()).parse(value);");
                  pw.println("        }");
                  pw.println("        catch (java.text.ParseException e){");
                  pw.println("            throw new java.lang.RuntimeException
(e.toString());");
                  pw.println("        }");
                }
                else if (simpleValueType.equals("java.util.Calendar")) {
pw.println("        java.util.Calendar cal = java.util.Calendar.getInstance
();");
        pw.println("        try {"};
                           // CODE CHANGES START 
pw.println("        java.util.Date dt = ((java.text.DateFormat) new 
java.text.SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\")).parse
(value);");                   
            // CODE CHANGES END

pw.println("          cal.setTime(dt);");
                  pw.println("          this.value = cal;");
                  pw.println("        }");
                  pw.println("        catch (java.text.ParseException e){");
                  pw.println("            throw new java.lang.RuntimeException
(e.toString());");
                  pw.println("        }");
                }                
                else {
//-------------
}

Please comment on the following changes and suggest any better solution.
Dims will it have any regression bug?

Mime
View raw message