我有以下类型的 wsdl 文件:
<xs:complexType name="someName">
....
</xs:complexType>
<xs:complexType name="someOtherName">
....
</xs:complexType>
我想要实现的是让这些类型实现通用接口
public interface Test {
//methods that already exist in the types
}
为了实现这一点,我创建了绑定文件:
<?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>
还配置了插件:
<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>
旗帜
<xjcArg>-Xequals</xjcArg>
<xjcArg>-XtoString</xjcArg>
已考虑在内,我生成的类具有以下签名:
public class SomeName implements ToString, Equals{...}
但是,即使考虑到 -Xinheritance 选项(在我添加对 jaxb2-basics 的依赖之前,它抱怨未知选项),也不会对代码生成产生任何影响。 绑定中的 XPath 是正确的,并且考虑了绑定 例如,如果代替
<inheritance:implements>com.mycompany.package.Test</inheritance:implements>
我提供:
<jaxb:class name="changedName"/>
类将以更改的名称生成,但它们仍然不会实现我想要的接口。
您知道哪里出了问题吗? 我怀疑问题出在绑定文件上,但我无法确定确切的位置。