Skip to main content

Using different package names for bindings and wsdl using the jaxws maven plugin

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
balteo
Offline
Joined: 2003-06-11

We have a special requirement with our application: files generated against the wsdl should have a given package name and files generated against xsd files should have another package name.

There does not seem to have a way to customize this with the jaxws maven plugin. Here is our current configuration:

    <execution>
        <id>wsimport-finderpro</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>wsimport</goal>
        </goals>
        <configuration>
            <bindingDirectory>src/main/resources/xml-resources/web-service-references/B2T_DataModel.asmx/xsd</bindingDirectory>
            <bindingFiles>
                <bindingFile>ServerResponse_login.xsd</bindingFile>
                <bindingFile>OpenDirectAccessSession.xsd</bindingFile>
            </bindingFiles>
            <!--wsdls file directory -->
            <wsdlDirectory>src/main/resources/xml-resources/web-service-references/B2T_DataModel.asmx/wsdl</wsdlDirectory>
            <!-- which wsdl file -->
            <wsdlFiles>
                <wsdlFile>B2T_DataModel.asmx.wsdl</wsdlFile>
            </wsdlFiles>
            <!-- Keep generated files -->
            <keep>true</keep>
            <!-- Package name -->
            <packageName>com.mycompany.world.worldlink.finderpro.ws</packageName>
            <!-- generated source files destination-->
            <sourceDestDir>target/generated-code/src</sourceDestDir>
            <staleFile>target/jaxws/fp/.staleFlag</staleFile>
            <target>2.1</target>
        </configuration>
    </execution>

Can anyone please advise?

edit 1: I came up with the following code:

            <execution>
                <id>wsimport-finderpro-01</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>wsimport</goal>
                </goals>
                <configuration>
                    <bindingDirectory>src/main/resources/xml-resources/web-service-references/B2T_DataModel.asmx/xsd</bindingDirectory>
                    <bindingFiles>
                        <bindingFile>OpenDirectAccessSession.xsd</bindingFile>
                    </bindingFiles>
                    <!--wsdls file directory -->
                    <wsdlDirectory>src/main/resources/xml-resources/web-service-references/B2T_DataModel.asmx/wsdl</wsdlDirectory>
                    <!-- which wsdl file -->
                    <wsdlFiles>
                        <wsdlFile>B2T_DataModel.asmx.wsdl</wsdlFile>
                    </wsdlFiles>
                    <!-- Keep generated files -->
                    <keep>true</keep>
                    <!-- Package name -->
                    <packageName>com.ids.world.worldlink.finderpro.xmlstubs</packageName>
                    <!-- generated source files destination-->
                    <sourceDestDir>target/generated-code/src</sourceDestDir>
                    <staleFile>target/jaxws/fp-01/.staleFlag</staleFile>
                    <target>2.1</target>
                </configuration>
            </execution>
            <execution>
                <id>wsimport-finderpro-02</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>wsimport</goal>
                </goals>
                <configuration>
                    <bindingDirectory>src/main/resources/xml-resources/web-service-references/B2T_DataModel.asmx/xsd</bindingDirectory>
                    <bindingFiles>
                        <bindingFile>GetAllMyEntityQuotes.xsd</bindingFile>
                    </bindingFiles>
                    <!--wsdls file directory -->
                    <wsdlDirectory>src/main/resources/xml-resources/web-service-references/B2T_DataModel.asmx/wsdl</wsdlDirectory>
                    <!-- which wsdl file -->
                    <wsdlFiles>
                        <wsdlFile>B2T_DataModel.asmx.wsdl</wsdlFile>
                    </wsdlFiles>
                    <!-- Keep generated files -->
                    <keep>true</keep>
                    <!-- Package name -->
                    <packageName>com.ids.world.worldlink.finderpro.xmlstubs.allMyEntityQuotes</packageName>
                    <!-- generated source files destination-->
                    <sourceDestDir>target/generated-code/src</sourceDestDir>
                    <staleFile>target/jaxws/fp-02/.staleFlag</staleFile>
                    <target>2.1</target>
                </configuration>
            </execution>

The issue is that I noticed that many classes are regenerated several times (here x2) and I end up with same classes in different packages.

How can I ensure that classes generated for the wsdl are generated once and classes for the xsd are generated and placed in their respective package?