Reputation: 1962
See below, I have 3 projects as mentioned.
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)
Both AnimalService.wsdl
and PersonService.wsdl
imports the Age.xsd schema as mentioned below:
<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>
Question:
How to tell cxf-codegen wsdl2java
to do not generate code for AgeType (which is in namespace http://xmlns.common/age) and use common.xmlns.age.AgeType instead of com.person.AgeType and com.animal.AgeType in respective projects by supplying the Common
project as dependency?
Upvotes: 6
Views: 8609
Reputation: 1962
Found the answer. We need to use -nexclude
in the extraarg
as follows with Common
project dependency added to Animal
and Person
project.
<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>
The syntax is:
<extraarg>-nexlude</extraarg>
<extraarg>namespace to be excluded=package where the JAXB generated classes available</extraarg>
Upvotes: 9