On 07/27/2010 11:30 PM, Glen Mazza wrote:

Here's some more info, apparently JAXB requires it (union regulations, I
guess).  But you can apparently change the package name (possibly the class
name too) if you wish:
[1] http://forums.java.net/jive/message.jspa?messageID=210403

Ok, I've read that thread and all *seems* - I'm precautious now ;) - to work fine : xsd:dateTime and xsd:date are replaced by java.util.Date.

So, FYI, what I did in the end is :

-= jaxb-binding.xml =-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings version="2.0"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb";
               xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc";
               xmlns:xs="http://www.w3.org/2001/XMLSchema";>
    <jaxb:globalBindings localScoping="nested"
                         collectionType="java.util.ArrayList"
                         generateValueClass="true">
<xjc:javaType name="java.util.Date" xmlType="xs:dateTime" adapter="be.ucm.career.converter.jaxb.DateTimeAdapter"/> <xjc:javaType name="java.util.Date" xmlType="xs:date" adapter="be.ucm.career.converter.jaxb.DateAdapter"/>
        <xjc:serializable uid="2"/>
    </jaxb:globalBindings>
</jaxb:bindings>

And created two Adapters (the ones that have been generated, but renamed and now "owned" by my code, as Kohsuje says), calling CXF's code :

-= DateTimeAdapter =-

public class DateTimeAdapter extends XmlAdapter<String, Date> {

    public Date unmarshal(String value) {
return (org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime(value));
    }

    public String marshal(Date value) {
return (org.apache.cxf.tools.common.DataTypeAdapter.printDateTime(value));
    }
}

-= DateAdapter =-

public class DateAdapter extends XmlAdapter<String, Date> {

    public Date unmarshal(String value) {
return (org.apache.cxf.tools.common.DataTypeAdapter.parseDate(value));
    }

    public String marshal(Date value) {
return (org.apache.cxf.tools.common.DataTypeAdapter.printDate(value));
    }
}

And the generated classes now use the annotation :

@XmlElement(name = "CreationDate", required = true, type = String.class)
    @XmlJavaTypeAdapter(DateAdapter.class)
    @XmlSchemaType(name = "date")
    protected Date creationDate;
    @XmlElement(name = "LastUpdateDate", type = String.class)
    @XmlJavaTypeAdapter(DateAdapter.class)
    @XmlSchemaType(name = "date")
    protected Date lastUpdateDate;

for example.

So in the end I haven't used the elements showed at wsdl2java help page.

Also, middle bullet in the "Other Notes" section of Item #2 here:
[2]
http://www.jroller.com/gmazza/entry/customizing_jaxb_artifacts#BindingFile

You may need to use the xjc:javaType instead of jaxb:javaType, as Kohsuke
wrote in [1] above.

Glen

Thanks for your patience, I really was confused but I fanally made it thanks to you.

Regards.

--
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Reply via email to