[JAVA-SOAP] Customize date type to string in client code
- Create a binding file with name common-binding.xjb or whatever with the content bellow
<?xml version='1.0' encoding='UTF-8'?><jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings>
<jaxb:serializable uid="1" />
<jaxb:javaType name="String" xmlType="xsd:dateTime" />
<jaxb:javaType name="String" xmlType="xsd:date" />
<jaxb:javaType name="String" xmlType="xsd:time" />
</jaxb:globalBindings>
</jaxb:bindings>
- In the pom.xml file, adding a plugin like:
<plugin> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/DynamicsGP.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/DynamicsGP.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
<defaultOptions>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/wsdl/common-binding.xjb</bindingFile>
</bindingFiles>
</defaultOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
No comments:
Post a Comment