1

I am trying to generate java classes out of wsdl file using axis2. The code is being generated however the destination directory is not correct.

After running the package or compile command I end up having two packages:

  • domain.company.service
  • src.domain.company.company.schema

All the classes under domain.company.service are as expected. All the files under src.domain.company.company.schema are having the namespace domain.company.company.schema

How do I get rid of the src directory added as a prefix to the generated schemas? Please note that I cannot share the WSDL files. I have looked everywhere inside of them and I could not find the src any where.

Desired result

  • Namespace in all of the classes is src.domain.company.company.schema

  • Instead of having the classes under src/domain/company/company/schema

  • I want them under domain/company/company/schema

My pom.xml file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework</groupId>
        <artifactId>gs-spring-boot-docker</artifactId>
    <version>0.1.0</version>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
    </parent>
    <properties>
        <java.version>1.8</java.version>
        <axis2.version>1.7.9</axis2.version>
        <log4j.version>1.2.17</log4j.version>
        <mapstruct.version>1.3.1.Final</mapstruct.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.ws/spring-ws-core -->
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20180130</version>
        </dependency>
        <!-- Import Axis2 dependencies used to generate the stub files -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>${axis2.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>${axis2.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>${axis2.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>${axis2.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-xmlbeans</artifactId>
            <version>${axis2.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-jaxws -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-jaxws</artifactId>
            <version>${axis2.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-jaxbri -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-jaxbri</artifactId>
            <version>${axis2.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- Axis2 plugin used to generate stubs from wsdl files -->
            <plugin>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                <version>${axis2.version}</version>
                <executions>
                    <execution>
                        <id>wsdl-serviceHub</id>
                        <goals>
                            <goal>wsdl2code</goal>
                        </goals>
                        <configuration>
                            <packageName>domain.company.service</packageName>
                            <wsdlFile>http://domain-name.com/service.wsdl
                            </wsdlFile>
                            <databindingName>jaxbri</databindingName>
                            <outputDirectory>src/main/java</outputDirectory>
                            <flattenFiles>true</flattenFiles>
                            <overWrite>true</overWrite>
                            <suppressPrefixes>true</suppressPrefixes>
                        </configuration>
                    </execution>
            </plugin>
        </plugins>
    </build>

</project>
thedethfox
  • 1,651
  • 2
  • 20
  • 38
  • Having the same problem – AmsterdamLuis Jan 22 '21 at 11:50
  • I did not end up solving the issue sadly, because the project was discontinued. A hacky way of solving the issue is to run a script after the installation that removes the src directory. However, this is not clean. Best of luck – thedethfox Feb 19 '21 at 20:35

1 Answers1

1

Inside the

<configuration>

section, use:

<targetSourceFolderLocation>.</targetSourceFolderLocation>

and eventually remove, or adjust accordingly, the <packageName> parameter.
The "." (dot character) stands, of course, for the current directory symbol.


This is a little bit hackish but – you know – always better than nothing, and surely better than having to write an additional command-line script just to rearrange the directories' structure.