8

I'm able to use generate classes with a relative wsdlLocation when I specify each file, such as <wsdlOptions> <wsdlOption> <wsdl>${basedir}/src/main/resources/sample.wsdl</wsdl> <wsdlLocation>classpath:wsdl/sample.wsdl</wsdlLocation> </wsdlOption> </wsdlOptions>

Instead, I would like to use <wsdlRoot> so I dont need to specify each wsdl for which to generate classes.

E.g.

<wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot> <includes> <include>*.wsdl</include> </includes>

This works to generate classes for each wsdl in the directory, however, the wsdlLocation in the generated class is an absolute path to where the wsdl is located on my machine. I would like a relative path, so the code is more portable. Is it possible to specify a relative wsdlLocation when using wsdlRoot?

Thank you

mav
  • 129
  • 1
  • 9
  • Have you found a solution for this? I just had this problem. I do not want to specify each .wsdl file and still need to set the wsdlLocation to the relative classpath-path. – oli-ver Feb 19 '18 at 12:56

1 Answers1

0

You can specify an extra option -wsdlLocation with an empty value. In the generated XXX_Service code, it says WSDL_LOCATION = null;.

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.2.4</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/src/main/java</sourceRoot>
                <wsdlRoot>${basedir}/src/main/webapp/WEB-INF/wsdl/</wsdlRoot>
                <defaultOptions>
                    <defaultExcludesNamespace>true</defaultExcludesNamespace>
                    <extraargs>
                        <extraarg>-wsdlLocation</extraarg>
                        <extraarg> </extraarg>
                    </extraargs>
                </defaultOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

You can find similar excerpt in pom.xml of my previous CXF project here: https://github.com/htr3n/loan-approval-portal/blob/master/pom.xml.

Alex
  • 128
  • 2
  • 9