Here is the patch against trunk. I also added in org.apache.xmlrpc.util the old DateTool from 2.0.1
explanations : - restore association of dateTime.iso8601 with java.util.Date and DateTool for serial/parse - add Calendar object support as an extension. Which such configuration, XML-RPC 3.0 is now compatible with older XML-RPC implementations 1.2/2.0 and PHP client I tested. Regards 2006/5/16, Henri Gomez <[EMAIL PROTECTED]>:
When I saw SPEC I see Date should be used not Calendar. Using Calendar instead of Date broke link with existing XML-RPC implementations, including XML-RPC 1.2 and 2.0 so we should use Date. Also the format is : <dateTime.iso8601> date/time 19980717T14:08:55 Nothing like AAAA-MM-JJTHH:MM:SS+ZZ:ZZ (ex: 2005-11-21T00:00:00+01:00), which is the SOAP date encoding. My patch restore use of java.util.Date as previously and provide Calendar as an extension. I'll send it tomorrow here. Regards 2006/5/16, Jochen Wiedmann <[EMAIL PROTECTED]>: > John Wilson wrote: > > > By all means introduce an extension which allows this form but the > > unextended implementation should conform to the standard. > > As for the last part: I do believe we all agree on that. Question is whether > implicit support is acceptable, following the mantra "strict on the output, > lazy on the input". Personally, I'd vote in favour of that. > > Henri, a suggested solution: I believe we do agree that support for > java.util.Calendar as well as java.util.Date is easy when creating XML. > However, we could possibly offer a solution for the parsing side too: The > method ReflectiveXmlRpcHandler.execute() could check for instances of > java.util.Calendar. If it detects such instances, then it could check > whether the corresponding parameter should be java.util.Date and, if so, > convert it. That way we should both be upwards compatible and be able to > offer timezone support. > > > Jochen > >
Index: C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/common/TypeFactoryImpl.java =================================================================== --- C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/common/TypeFactoryImpl.java (revision 406591) +++ C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/common/TypeFactoryImpl.java (working copy) @@ -1,12 +1,12 @@ /* * Copyright 1999,2005 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,6 +18,7 @@ import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; @@ -27,7 +28,7 @@ import org.apache.xmlrpc.parser.BigIntegerParser; import org.apache.xmlrpc.parser.BooleanParser; import org.apache.xmlrpc.parser.ByteArrayParser; -import org.apache.xmlrpc.parser.DateParser; +import org.apache.xmlrpc.parser.CalendarParser; import org.apache.xmlrpc.parser.DoubleParser; import org.apache.xmlrpc.parser.FloatParser; import org.apache.xmlrpc.parser.I1Parser; @@ -38,6 +39,7 @@ import org.apache.xmlrpc.parser.NodeParser; import org.apache.xmlrpc.parser.NullParser; import org.apache.xmlrpc.parser.ObjectArrayParser; +import org.apache.xmlrpc.parser.DateParser; import org.apache.xmlrpc.parser.SerializableParser; import org.apache.xmlrpc.parser.StringParser; import org.apache.xmlrpc.parser.TypeParser; @@ -45,7 +47,7 @@ import org.apache.xmlrpc.serializer.BigIntegerSerializer; import org.apache.xmlrpc.serializer.BooleanSerializer; import org.apache.xmlrpc.serializer.ByteArraySerializer; -import org.apache.xmlrpc.serializer.DateSerializer; +import org.apache.xmlrpc.serializer.CalendarSerializer; import org.apache.xmlrpc.serializer.DoubleSerializer; import org.apache.xmlrpc.serializer.FloatSerializer; import org.apache.xmlrpc.serializer.I1Serializer; @@ -57,6 +59,7 @@ import org.apache.xmlrpc.serializer.NodeSerializer; import org.apache.xmlrpc.serializer.NullSerializer; import org.apache.xmlrpc.serializer.ObjectArraySerializer; +import org.apache.xmlrpc.serializer.DateSerializer; import org.apache.xmlrpc.serializer.SerializableSerializer; import org.apache.xmlrpc.serializer.StringSerializer; import org.apache.xmlrpc.serializer.TypeSerializer; @@ -73,7 +76,7 @@ private static final TypeSerializer I4_SERIALIZER = new I4Serializer(); private static final TypeSerializer BOOLEAN_SERIALIZER = new BooleanSerializer(); private static final TypeSerializer DOUBLE_SERIALIZER = new DoubleSerializer(); - private static final TypeSerializer DATE_SERIALIZER = new DateSerializer(); + private static final TypeSerializer DATE_SERIALIZER = new DateSerializer(); private static final TypeSerializer BYTE_SERIALIZER = new I1Serializer(); private static final TypeSerializer SHORT_SERIALIZER = new I2Serializer(); private static final TypeSerializer LONG_SERIALIZER = new I8Serializer(); @@ -82,6 +85,7 @@ private static final TypeSerializer SERIALIZABLE_SERIALIZER = new SerializableSerializer(); private static final TypeSerializer BIGDECIMAL_SERIALIZER = new BigDecimalSerializer(); private static final TypeSerializer BIGINTEGER_SERIALIZER = new BigIntegerSerializer(); + private static final TypeSerializer CALENDAR_SERIALIZER = new CalendarSerializer(); private final XmlRpcController controller; @@ -140,8 +144,8 @@ } } else if (pObject instanceof Double) { return DOUBLE_SERIALIZER; - } else if (pObject instanceof Date) { - return DATE_SERIALIZER; + } else if (pObject instanceof Date) { + return DATE_SERIALIZER; } else if (pObject instanceof byte[]) { return new ByteArraySerializer(); } else if (pObject instanceof Object[]) { @@ -160,7 +164,7 @@ if (pConfig.isEnabledForExtensions()) { return BIGINTEGER_SERIALIZER; } else { - throw new SAXException(new XmlRpcExtensionException("BigInteger values aren't supported, if isEnabledForExtensions() == false")); + throw new SAXException(new XmlRpcExtensionException("BigInteger objects aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof BigDecimal) { if (pConfig.isEnabledForExtensions()) { @@ -166,7 +170,13 @@ if (pConfig.isEnabledForExtensions()) { return BIGDECIMAL_SERIALIZER; } else { - throw new SAXException(new XmlRpcExtensionException("BigDecimal values aren't supported, if isEnabledForExtensions() == false")); + throw new SAXException(new XmlRpcExtensionException("BigDecimal objects aren't supported, if isEnabledForExtensions() == false")); + } + } else if (pObject instanceof Calendar) { + if (pConfig.isEnabledForExtensions()) { + return CALENDAR_SERIALIZER; + } else { + throw new SAXException(new XmlRpcExtensionException("Calendar objects aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Serializable) { if (pConfig.isEnabledForExtensions()) { @@ -200,6 +210,8 @@ return new BigDecimalParser(); } else if (BigIntegerSerializer.BIGINTEGER_TAG.equals(pLocalName)) { return new BigIntegerParser(); + } else if (CalendarSerializer.CALENDAR_TAG.equals(pLocalName)) { + return new CalendarParser(); } else if (SerializableSerializer.SERIALIZABLE_TAG.equals(pLocalName)) { return new SerializableParser(); } @@ -210,8 +222,8 @@ return new BooleanParser(); } else if (DoubleSerializer.DOUBLE_TAG.equals(pLocalName)) { return new DoubleParser(); - } else if (DateSerializer.DATE_TAG.equals(pLocalName)) { - return new DateParser(); + } else if (DateSerializer.DATE_TAG.equals(pLocalName)) { + return new DateParser(); } else if (ObjectArraySerializer.ARRAY_TAG.equals(pLocalName)) { return new ObjectArrayParser(pConfig, pContext, this); } else if (MapSerializer.STRUCT_TAG.equals(pLocalName)) { Index: C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/parser/CalendarParser.java =================================================================== --- C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/parser/CalendarParser.java (revision 406919) +++ C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/parser/CalendarParser.java (working copy) @@ -24,7 +24,7 @@ /** Parser for integer values. */ -public class DateParser extends AtomicParser { +public class CalendarParser extends AtomicParser { private static final XsDateTimeFormat f = new XsDateTimeFormat(); protected void setResult(String pResult) throws SAXException { Index: C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/parser/DateParser.java =================================================================== --- C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/parser/DateParser.java (revision 406919) +++ C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/parser/DateParser.java (working copy) @@ -1,38 +0,0 @@ -/* - * Copyright 1999,2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.xmlrpc.parser; - -import java.text.ParseException; - -import org.apache.ws.commons.util.XsDateTimeFormat; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - - -/** Parser for integer values. - */ -public class DateParser extends AtomicParser { - private static final XsDateTimeFormat f = new XsDateTimeFormat(); - - protected void setResult(String pResult) throws SAXException { - try { - super.setResult(f.parseObject(pResult.trim())); - } catch (ParseException e) { - throw new SAXParseException("Failed to parse integer value: " + pResult, - getDocumentLocator()); - } - } -} Index: C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/serializer/CalendarSerializer.java =================================================================== --- C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/serializer/CalendarSerializer.java (revision 406919) +++ C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/serializer/CalendarSerializer.java (working copy) @@ -1,12 +1,12 @@ /* * Copyright 1999,2005 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,14 +20,17 @@ import org.xml.sax.SAXException; -/** A [EMAIL PROTECTED] TypeSerializer} for date values. +/** A [EMAIL PROTECTED] TypeSerializer} for Calendar values. */ -public class DateSerializer extends TypeSerializerImpl { - /** Tag name of a date value. +public class CalendarSerializer extends TypeSerializerImpl { + /** Tag name of a Calendar value. */ - public static final String DATE_TAG = "dateTime.iso8601"; - private static final XsDateTimeFormat format = new XsDateTimeFormat(); + public static final String CALENDAR_TAG = "calendar"; + + private static final String EX_CALENDAR_TAG = "ex:" + CALENDAR_TAG; + + private static final XsDateTimeFormat format = new XsDateTimeFormat(); public void write(ContentHandler pHandler, Object pObject) throws SAXException { - write(pHandler, DATE_TAG, format.format(pObject)); + write(pHandler, CALENDAR_TAG, EX_CALENDAR_TAG, format.format(pObject)); } } \ No newline at end of file Index: C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/serializer/DateSerializer.java =================================================================== --- C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/serializer/DateSerializer.java (revision 406919) +++ C:/eclipse31/workspace/ws-xmlrpc/common/src/main/java/org/apache/xmlrpc/serializer/DateSerializer.java (working copy) @@ -1,33 +0,0 @@ -/* - * Copyright 1999,2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.xmlrpc.serializer; - -import org.apache.ws.commons.util.XsDateTimeFormat; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - - -/** A [EMAIL PROTECTED] TypeSerializer} for date values. - */ -public class DateSerializer extends TypeSerializerImpl { - /** Tag name of a date value. - */ - public static final String DATE_TAG = "dateTime.iso8601"; - private static final XsDateTimeFormat format = new XsDateTimeFormat(); - public void write(ContentHandler pHandler, Object pObject) throws SAXException { - write(pHandler, DATE_TAG, format.format(pObject)); - } -} \ No newline at end of file