javawsdljax-wsmulejaxws-maven-plugin

Maven jax-ws plugin wsimport giving "The nested type x cannot hide an enclosing type" in generated code


Detail:

Example maven pom content:

<plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <id>wsdla-exec-1</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <packageName>com.yourcompany.package</packageName>
                            <target>2.1</target>
                            <verbose>true</verbose>
                            <!-- Fix naming resolution due to ChangeOrderResponse duplicate stanza -->
                            <args>
                                <arg>-B-XautoNameResolution</arg>
                            </args>
                            <wsdlDirectory>src/main/resources</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFiles>service1.wsdl</wsdlFiles>
                            </wsdlFiles>
                            <wsdlLocation>/*</wsdlLocation>
                            <sourceDestDir>src/main/java</sourceDestDir>
                        </configuration>
                    </execution>
                    <execution>
                        <id>wsdla-exec-2</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <packageName>com.yourcompany.package</packageName>
                            <target>2.1</target>
                            <verbose>true</verbose>
                            <!-- Fix naming resolution due to ChangeOrderResponse duplicate stanza -->
                            <args>
                                <arg>-B-XautoNameResolution</arg>
                            </args>
                            <wsdlDirectory>src/main/resources</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFile>service2.wsdl</wsdlFile>
                            </wsdlFiles>
                            <wsdlLocation>/*</wsdlLocation>
                            <sourceDestDir>src/main/java</sourceDestDir>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Description:

I have been generating client code from wsdl's for quite some time now within Mule and it has always been fairly straight forward and productive but now I've hit a snag for which I might get a pointer in the right direction here.

Basically, in the generated code from the wsdl there is a nested class of the same name as the container class and this is producing the colour red in my projects where I'm using this wsdl.

What I know:

I can change the code manually and viola, or better yet I can change the wsimport to use a static file (copied from the url - incl all the xsd's) and change those files. However both seem wrong!

Is there a way I can manipulate the process of code generation or should I ask the vendor to make changes? What are your thoughts?

Many thanks, truly appreciate any input.


Solution

  • The answer lied in the fact that the vendor actually intended consumers to use xmlbeans for bindings and not jaxb as per the current jax-ws standard. So in order to create client code from the wsdl I was able to do either one of the following.

    On windows (if you have the tool):

    md YourServiceFolderName
    WSDL2java -uri YourService.wsdl -ss -sd -ssi -g -d xmlbeans -o YourServiceFolderName
    

    With Maven plugin, under your "plugins" tag (be sure to sort out the dependancies you'll need as well - not given here):

                <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>2.7.8</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>YourService?wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-databinding</extraarg>
                                        <extraarg>xmlbeans</extraarg>
                                    </extraargs>
                                </wsdlOption>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    

    This should give you all the java artefacts you need to get on with your service consumption. Hope this helps someone.