Skip to content

Instantly share code, notes, and snippets.

@sachin-handiekar
Created November 25, 2013 11:15
Show Gist options
  • Save sachin-handiekar/7639830 to your computer and use it in GitHub Desktop.
Save sachin-handiekar/7639830 to your computer and use it in GitHub Desktop.
JAXB Binding (WSDL2Java )- XMLGregorianCalendar to java.util.Date
<jaxws:bindings wsdlLocation="SampleService.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://example.com/service/SampleService/']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:javaType name="java.util.Date" xmlType="xs:date"
parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
</jxb:globalBindings>
</jaxws:bindings>
</jaxws:bindings>
@sachin-handiekar
Copy link
Author

  • Maven Dependency
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-tools-common</artifactId>
    <version>${cxf.version}</version>
    <scope>provided</scope>
</dependency>

@sachin-handiekar
Copy link
Author

  • WSDL2Java plugin
<wsdlOptions>
   <wsdlOption>
    <wsdl>${basedir}/src/main/resources/wsdl/SampleService.wsdl</wsdl>
    <wsdlLocation>classpath:wsdl/SampleService.wsdl</wsdlLocation>
    <bindingFiles>
        <bindingFile>
            ${basedir}/src/main/resources/wsdl/dateBinding.xml
        </bindingFile>
    </bindingFiles>
</wsdlOption>
</wsdlOptions>

@mhewedy
Copy link

mhewedy commented Oct 30, 2017

<version>2.7.0</version>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment