axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pétur Runólfsson <pe...@betware.com>
Subject RE: [Axis2] Bring back hours, minutes, seconds when Date is formatted in SimpleTypeMapper
Date Fri, 12 Jun 2009 13:15:25 GMT
I would prefer not to have to use java.util.Calendar to represent timestamps. There are a couple
of reasons:

* The rest of the application uses java.util.Date for this purpose. Having to use Calendar
for the  SOAP layer would introduce extra conversions and make the code less consistent.
* Date includes both date and time. Mapping it to xs:date loses information. The mapping for
other types is not lossy (as far as I can tell).
* It would be very easy to accidentally use Date instead of Calendar. This error wouldn't
be detected until at runtime, and might easily slip through testing depending on how the dates
are being used (sometimes timestamps are stored with both date and time, but only the date
portion might be displayed).

That said, here's a different patch that doesn't modify how Axis2 formats dates, but would
solve the issue for me.

This moves the implementation of SimpleTypeMap into a new class SimpleTypeMap, that has instance
methods instead of static methods. A service parameter, SimpleTypeMap, can be used to specify
a subclass of SimpleTypeMap to use. The implementation of SimpleTypeMap is the same as SimpleTypeMapper
was, except that getStringValue has been split into different protected methods and getCurrentMessageContext
is no longer called inside getStringValue since AxisService is now available as a member.

This allows much more flexibility than the earlier patch, at the cost that the only way to
take advantage of it is to write some code (the first patch required only configuration).
Potential use cases for this include:

* Detailed control of how dates are formatted (should timezone be included? which timezone?
use offsets (+00:00) or canonical representation (Z)? map Date to xs:date, xs:dateTime, xs:time
or something else? include milliseconds or not?)
* Custom types can be mapped to simple types (for example Joda date and time classes can be
mapped to xs:dateTime etc., or an Image class might be mapped to base64binary instead of being
treated as a complex type).

I actually prefer this patch to the first one (for example, the first patch lacked a corresponding
option in Java2WSDL, but for this patch such an option already exists: -sg).

Regards,

Pétur Runólfsson
Betware
________________________________________
From: Amila Suriarachchi [amilasuriarachchi@gmail.com]
Sent: Friday, June 12, 2009 05:30
To: axis-dev@ws.apache.org
Subject: Re: [Axis2] Bring back hours, minutes, seconds when Date is formatted  in SimpleTypeMapper

On Thu, Jun 11, 2009 at 8:02 PM, Pétur Runólfsson <petur@betware.com<mailto:petur@betware.com>>
wrote:
Hi,

It seems that the schema type for java.util.Date has changed from xs:dateTime to xs:date in
Axis2 1.5. This is preventing me from upgrading, since the application depends on having both
the date and time available for many operations.

Now the convention is to map java.util.Date to xs:date and java.util.Calendar to xs:datetime
is it possible you to convert your app to use Calendar instead of date where you need to have
datetime.
here the reason is that if you represent something like birthday which represent in java as
java.util.date and should map to a xs:date.

thanks,
Amila.



The attached patch adds a configuration option to change the schema type back to xs:dateTime.
When the service parameter JavaDateSchemaType is set to xs:dateTime, the format used by SimpleTypeMapper
is yyyy-MM-dd'T'HH:mm:ss.SSSZ, otherwise it is yyyy-MM-dd like before. Note that the format
is different from Axis2 1.4.1 because of the TimeZone parameter that was added in 1.5. Setting
the TimeZone to GMT restores the old behavior completely.

This patch only modifies the formatting in SimpleTypeMapper. Java2WSDL still treats Date as
xs:date. This doesn't matter for me, since the schema is easy to fix using a custom SchemaGenerator
or by running the wsdl through sed. Still, it doesn't seem hard to add the corresponding support
to Java2WSDL.

This fixes issues AXIS2-4329 and AXIS2-4370.

Regards,

Pétur Runólfsson
Betware

The content of this e-mail, together with any of its attachments, is for the exclusive and
confidential use of the named addressee(s) and it may contain legally privileged and confidential
information and/or copyrighted material. Any other distribution, use or reproduction without
the sender's prior consent is unauthorized and strictly prohibited. If you have by coincidence,
mistake or without specific authorization received this e-mail in error, please notify the
sender by e-mail immediately, uphold strict confidentiality and neither read, copy, transfer,
disseminate, disclose nor otherwise make use of its content in any way and delete the material
from your computer.

The content of the e-mail and its attachments is the liability of the individual sender, if
it does not relate to the affairs of Betware.
Betware does not assume any civil or criminal liability should the e-mail or it´s attachments
be virus infected.



--
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

The content of this e-mail, together with any of its attachments, is for the exclusive and
confidential use of the named addressee(s) and it may contain legally privileged and confidential
information and/or copyrighted material. Any other distribution, use or reproduction without
the sender's prior consent is unauthorized and strictly prohibited. If you have by coincidence,
mistake or without specific authorization received this e-mail in error, please notify the
sender by e-mail immediately, uphold strict confidentiality and neither read, copy, transfer,
disseminate, disclose nor otherwise make use of its content in any way and delete the material
from your computer.

The content of the e-mail and its attachments is the liability of the individual sender, if
it does not relate to the affairs of Betware.
Betware does not assume any civil or criminal liability should the e-mail or it´s attachments
be virus infected.

Mime
View raw message