WSDL2Code (Maven) auto-generates corrupt classes (packages)
Asked Answered
C

6

5

I am currently in the process of replacing the IBM WebService framework with Axis2. When generating the code from the WSDL file, I use the Maven plugin WSDL2Code. However, the code created is always wrong. Or rather, the packagenames are always wrong, which in turn makes every method called uncallable (creating even more errors, up to 10.000+ errors in eclipse).

Here's an example of what is actually going on (this is just an example I made specifically to get advice):

      <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.4.1</version>
            <executions>
                <execution>
                    <id>Test</id>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <packageName>test.testpackage</packageName>
                        <databindingName>xmlbeans</databindingName>
                        <wsdlFile>${basedir}/wsdl/service.wsdl</wsdlFile>
                        <outputDirectory>${basedir}/testdirectory</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

In theory, this should generate code with the package name "test.testpackage" in the directory testdirectory/test/testpackage. However, instead it creates the following package: Src.test.testpackage in the directory testdirectory.src.test.testpackage. It always adds a "src" to both package name and directory - if I change the package name to src.test.testpackage, it will generate the following package: src.src.test.testpackage.

This, of course, leads to a huge problem, because every generated file has the following error: "The declared package "src.test.testpackage" does not match the expected package "src.src.test.testpackage"

I'm at a complete loss here. I simply can't find any reason at all why it should add "src" everywhere. I've noticed an auto-generated build.xml file containing a value called sourcedirectory = x/src (or something similar), but there's nothing I can do to affect this value (trying to change it and then save the file makes no difference, obviously, since it's just generated again the next time I run maven).

Oh, and I generally use the command "mvn clean install" and version 1.4.1 of WSDL2Code, so it's not one of the old wsdl2code:wsdl2code bugs.

If anyone has any idea of what is actually wrong here, I'd greatly appreciate it.

Thanks in advance.

Cicatrix answered 2/12, 2008 at 12:34 Comment(0)
H
9

Version 1.4.1 has a few more configuration options that are not really documented (have a look at the the source of org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo)...

Just use <flattenFiles>true</flattenFiles> - that should solve your problem :-)

Hanway answered 18/2, 2009 at 16:23 Comment(2)
Thanks, it does indeed work, but can you explain why it works?Irinairis
Thank you @Jo Ehm, this is exactly what I needed to know.Akan
N
2

This question is quite old, so I don't know if you're still having the problem...

I would recommend using Axistools Maven Plugin instead, it worked great in our case.

Nobile answered 6/5, 2009 at 9:9 Comment(0)
N
0

Maybe 'src' is part of ${basedir} ?

Nicholenicholl answered 2/12, 2008 at 12:44 Comment(0)
C
0

I'm afraid not. Even if it was, the strange problem shouldn't occur then - the path would then be correct being testdirectory/src/test/testpackage, thus causing no problem with the package name. The problem now arises because it is placed in a directory the package does not expect - it expects ${basedir}/testdirectory/insert.package.here.divided.by./, but instead it gets ${basedir}/testdirectory/src/insert.package.here.divided.by./.

The src should not be present in that part of the path.

Cicatrix answered 2/12, 2008 at 13:29 Comment(1)
Was this in reply to leppie? If so use comments in the future.Foretaste
S
0

This is connected with those "genius" of(or user of) maven/axis2 that practically takes decisions for you ... see this: [Axis2 mailing list entry][1]

[1]: http://markmail.org/search/?q=[Axis2]+indrit#query:[Axis2 Mailing List entry]%20indrit+page:1+mid:a34wbp7l3pljagsz+state:results

Straitjacket answered 29/9, 2009 at 10:22 Comment(0)
S
0

I have recently faced the same issue and solved it by modifying the targetSourceFolderLocation as below. By default, it points to the src directory. so it generated package structure as testdirectory.src.test.testpackage in your case. please use below config and it should work as expected.

<outputDirectory>${basedir}</outputDirectory>
<packageName>test.testpackage</packageName>
<targetSourceFolderLocation>testdirectory</targetSourceFolderLocation>
Sustenance answered 7/7 at 22:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.