Apache cxf-codegen-plugin wsdl2java relative wsdlLocation

I can use generation classes with relative wsdlLocation when I specify each file, for example <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 don’t need to specify each wsdl to generate classes.

eg.

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

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

thanks

+6
source share
1 answer

You can specify the optional option -wsdlLocation with an empty value. In the generated XXX_Service code, this 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 a similar excerpt in pom.xml my previous CXF project here: https://github.com/htr3n/loan-approval-portal/blob/master/pom.xml .

0
source

All Articles