3
votes

I have a set of XSD (A and B) and their corresponding Java classes are generated by maven-jaxb2-plugin. Java classes are in package P1.

Beside, I have a WSDL which uses some types from XSD A and B.

However, when I generate Java classes from my WSDL with cxf-codegen-plugin, it generates types in package P2.

==> Types in P1 and P2 are strictly identicals.

My question is: how can I tell cxf-codegen-plugin to use existing package P1?

Thanks!

Hejk

1

1 Answers

-1
votes

If you take a look on the part where I specified packages you will find out two configurations. The first one is:

<packagename>http://www.schema.org/something=info.package.p1</packagename>

During compiling xsd to java classes all files that have schema http://www.schema.org/something will be stored into the info.package.p1 package. The second configuration serves if xsd files do not belong to the first schema they will be stored into default package info.package.p2. You can make this configuration separately for each of your schema.

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.7</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>src/main/java</sourceRoot>
                <wsdlRoot>${basedir}/src/main/resources/wsdl/</wsdlRoot>
                    <includes>
                        <include>*your.wsdl</include>
                    </includes>
                    <wsdlOptions>
                        <wsdlOption>
                            <wsdl>${basedir}/src/main/resources/wsdl/your.wsdl</wsdl>
                            <packagenames>
                                <packagename>http://www.schema.org/something=info.package.p1</packagename>
                                <packagename>info.package.p2</packagename>
                            </packagenames>
                            <bindingFiles>
                                <bindingFile>${basedir}/src/main/resources/bindingFile.xjb</bindingFile>
                            </bindingFiles>
                        </wsdlOption>
                    </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>