views:

1143

answers:

6

Hello,

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.

A: 

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

leppie
A: 

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.

Was this in reply to leppie? If so use comments in the future.
Adam
A: 

This is my major problem too. Cant seem to get rid of the src folder. When using WSDL2Java you can pass in a -f switch to remove the src directory. You would think they would have this option for this tool.

Has any solved this yet?

+4  A: 

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 :-)

Thanks, it does indeed work, but can you explain why it works?
Confusion
+2  A: 

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.

Thomas Marti
+1  A: 

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=%5BAxis2%5D+indrit#query%3A%5BAxis2 Mailing List entry]%20indrit+page:1+mid:a34wbp7l3pljagsz+state:results

Indrit