I'm generating java classes from soap
webservices wsdl
.
The requests do not share a common interface, but I'd like them to implement one, or extend a common class.
Therefore I'm trying to use the xcj-plugin
. The statement
<extraarg>-xjc-XautoInheritance-xmlRootElementsImplement=com.path.to.BaseInterface</extraarg>
should take care of this, and let all @XmlRootElement
annotated classes automatically implement the defined BaseInterface
.
But the generated classes are without that. No class is implementing this interface. Why? What might be wrong with the following configuration?
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<extraargs>
<extraarg>-xjc-XautoInheritance-xmlRootElementsExtend=com.path.to.BaseClass</extraarg>
<extraarg>-xjc-XautoInheritance-xmlRootElementsImplement=com.path.to.BaseInterface</extraarg>
<extraarg>-fe</extraarg>
<extraarg>cxf</extraarg>
<extraarg>-mark-generated</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.10-b140310.1920</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.8.2</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>0.8.2</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-jaxb-xjc</artifactId>
<version>2.2.4-1</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.1.10.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Please add -xjc-XautoInheritance
to activate the plugin.
See the following page for CXF usage of JAXB2 Basics plugins:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/CustomerService.wsdl</wsdl>
<bindingFiles>
<bindingFile>${basedir}/src/main/wsdl/binding.xml</bindingFile>
<bindingFile>${basedir}/src/main/wsdl/binding.xjb</bindingFile>
</bindingFiles>
<extraargs>
<extraarg>-xjc-XhashCode</extraarg>
<extraarg>-xjc-Xequals</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version><!-- version --></version>
</dependency>
</dependencies>
</plugin>
Disclaimer: I'm the author of JAXB2 Basics plugins.