I have wsdl file with following types:
<xs:complexType name="someName">
....
</xs:complexType>
<xs:complexType name="someOtherName">
....
</xs:complexType>
What I am trying to achieve is for this types to implement common interface
public interface Test {
//methods that already exist in the types
}
To achieve this, I created binding file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxws:bindings
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
jaxb:extensionBindingPrefixes="xjc inheritance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
wsdlLocation="my_wsdl.wsdl">
<enableWrapperStyle>true</enableWrapperStyle>
<enableAsyncMapping>false</enableAsyncMapping>
<jaxws:bindings node="//xs:complexType[@name='someName']">
<inheritance:implements>com.mycompany.package.Test</inheritance:implements>
</jaxws:bindings>
</jaxws:bindings>
and also configured plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>${jaxws-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>wsdl</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<xjcArgs>
<xjcArg>-Xinheritance</xjcArg>
<xjcArg>-Xequals</xjcArg>
<xjcArg>-XtoString</xjcArg>
</xjcArgs>
<genJWS>true</genJWS>
<bindingDirectory>${basedir}/src/main/resources/soap</bindingDirectory>
<bindingFiles>
<bindingFile>binding.xjb</bindingFile>
</bindingFiles>
<xnocompile>true</xnocompile>
<xdebug>true</xdebug>
<verbose>true</verbose>
<wsdlUrls>
<wsdlUrl>${project.basedir}/src/main/resources/soap/my_wsdl.wsdl</wsdlUrl>
</wsdlUrls>
<sourceDestDir>target/generated-sources/soap</sourceDestDir>
</configuration>
</execution>
</executions>
<extensions>true</extensions>
</plugin>
The flags
<xjcArg>-Xequals</xjcArg>
<xjcArg>-XtoString</xjcArg>
are taken into account, and my generated classes have following signature:
public class SomeName implements ToString, Equals{...}
but, the -Xinheritance option, even though taken into account (before I added dependency on jaxb2-basics, it was complaining about unknown option) is not having any effect on the code generation. the XPath in bindings is correct, and binding is taken into account for example, if instead of
<inheritance:implements>com.mycompany.package.Test</inheritance:implements>
I provide:
<jaxb:class name="changedName"/>
class will be generated with changed name, but they will still not implement the interface that I want.
Do you have any ideas what is wrong? I suspect issue is with binding file, but I cannot pin-point exact location.
You can try to follow this wiki page about the inheritence plugin in the official repository.
From what I see the main difference is the jaxws/jaxb prefix used in bindings.
You can also try to add extra debug in your maven build using
-X -eoptions to see debug output during classes generation.You can follow this migration guide on how to get the latest version of the jaxb-tools which is now all merged into the same location.
If it still doesnt work, come back and I'll look deeper, and if necessary, I'll create an issue in jaxb-tools' github repo
EDIT
After debugging the
wsimport, it seems that theextensionBindingPrefixesattribute you can set injaxb:bindingsis not taken into account when defined injaxws:bindingsand it seems to be by design according XSDIf you want to use bindings to customize the output with
extensionBindingPrefixesplugins, you need to externalize the XSD into is own file and then use the standardjaxb:bindingsprocess.The section of
wsdl:typesshould look like the following :And the
my_xsd.xsdfile would contain the schema definition elements.This also explains why defining it inline the WSDL makes it work (since the
extensionBindingPrefixeshas been defined onxs:schema)