wsdl2java - 如何忽略cxf-codegen-plugin中的特定模式并添加依赖项

时间:2015-04-15 11:56:29

标签: java maven wsdl2java cxf-codegen-plugin

见下文,我提到了3个项目。

Common
    Age.xsd (namespace: http://xmlns.common/age)
    generated/common/xmlns/age/AgeType.java
    pom.xml (cxf-xjc-plugin xsdtojava)


Person
    PersonService.wsdl (imports Age.xsd in wsd:types)
    generated/com/person/AgeType.java
    pom.xml (cxf-codegen-plugin wsdl2java)

Animal
    AnimalService.wsdl (imports Age.xsd in wsd:types)
    generated/com/animal/AgeType.java
    pom.xml (cxf-codegen-plugin wsdl2java)

AnimalService.wsdlPersonService.wsdl都会导入Age.xsd架构,如下所述:

<wsdl:definitions xmlns:cn="http://xmlns.common/age"
<wsdl:types>
    <xsd:schema>
    <xsd:import
        namespace="http://xmlns.common/age"
         schemaLocation="classpath:/common/xmlns/age/Age.xsd" />
    </xsd:import>
    </xsd:schema>
     <!-- cn:AgeType used in output message -->
    <!-- ignored -->
    </wsdl:definitions>

问题:

如何告诉cxf-codegen wsdl2java 不生成 AgeType的代码(位于命名空间http://xmlns.common/age中)并使用common.xmlns.age.AgeType而不是com.person通过提供Common项目作为依赖项,各项目中的.AgeType和com.animal.AgeType?

1 个答案:

答案 0 :(得分:2)

找到答案。我们需要在-nexclude中使用extraarg,如下所示,Common项目依赖项已添加到AnimalPerson项目中。

<wsdlOptions>
 <wsdlOption>
  <wsdl>${project.basedir}/src/main/resources/Animal.wsdl</wsdl>
  <wsdlLocation>classpath:Animal.wsdl</wsdlLocation>
  <extraargs>
   <extraarg>-nexclude</extraarg>
   <extraarg>http://xmlns.common/age=common.xmlns.age</extraarg>
  </extraargs>
 </wsdlOption>
</wsdlOptions>

语法为:

<extraarg>-nexlude</extraarg>
<extraarg>namespace to be excluded=package where the JAXB generated classes available</extraarg>