A simple^W dumb Map wrapper to use with JAXB

Java XML

I sometimes need to use java.util.Map objects in WebServices. As I’m building all my WebServices with the JAX-WS RI (using the Metro bundle). The block responsible for XML (un)marshalling of POJO, named JAXB, does not allows to directly use Maps as a soap operation parameter. For this purpose I’ve written the following simple class that allows me to wrap Maps in a POJO that JAXB is able to (un)marshall :

public class JAXBMapWrapper<KT, VT> {

    private Map<KT, VT> wrappedMap;

    public JAXBMapWrapper() {
        wrappedMap = new HashMap<KT, VT>();

    public Map<KT, VT> getWrappedMap() {
        return wrappedMap;

    public void setWrappedMap(final Map<KT, VT> givenMap) {
        wrappedMap = givenMap;


ATTENTION: I posted this some days ago and removed the post after understanding that this is simpler on the service side but that the client side gets cumbersome generated classes.. but google cache indexed the post in less than half a day.

Just don’t use this ! :) If you need to transmit Maps over JAX-WS webservices, do it the XmlAdapter way as advertised in the official Unofficial JAXB Guide instead.

JAXB Custom Binding for Joda-Time

Java XMLI’m extensively using Joda-Time for handling time in my Java development, client or server side. Joda-Time is the codebase of the coming RI implementation of JSR-310 that will hopefully ship in Java 7.

I often need to work with dates in web services implementations, here is the JAXB custom binding lines I use to un/marshall JodaTime types to standard xs:date and xs:dateTime XML Schema types.

Note : I’m using the RI implementation of JAXB spec bundled in Metro.
Continue reading “JAXB Custom Binding for Joda-Time”