java.util.Date property rendered as xs:string in xsd using JAX-WS (Apache CXF / Metro)

帅比萌擦擦* 提交于 2019-12-11 13:15:12

问题


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!

来源:https://stackoverflow.com/questions/15679849/java-util-date-property-rendered-as-xsstring-in-xsd-using-jax-ws-apache-cxf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!