java.util.Date property rendered as xs:string in x

2019-07-25 08:32发布

问题:

I generated some model classes based on a WSDL using apache cxf. I then added a jaxb bindingfile to convert all xs:dateTime and xs:date elements to java.util.date (instead of the default XMLGregorianCalendar):

<jxb:javaType name="java.util.Date" xmlType="xs:date"
                      parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDate"
                      printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDate"/>
       <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
                      parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
                      printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>

This all works very well and all xs:date and xs:dateTime properties of completype elements are generated as java.util.Date.

The problem arises when i try to create a Metro JAX-WS service based on these model objects. In mycase all java.util.Date fields are rendered as dataType xs:string in the .xsd file of the service.

I cannot find out why this is happening except for the fact the relevant model properties , after generation by cxf, are annotated with the following:

 @XmlElement(required = true, type = String.class)
    @XmlJavaTypeAdapter(Adapter1 .class)
    protected Date datumTijdBedrijfsdocument;

I can imagine that the type="String.class" could be the cause of all properties being generated as xs:string fields.

I could, of course, edit all objects manually but i am really looking for a solution in apache CFX of Metro to prevent this problem declaratively.

I hope you guys can help me out since this problem got me in a stalemate position

Thx!