I'm currently using the Apache CXF codegen plugin (version 3.1.1) for Maven to generate sources from our client-provided WSDL. I have the wsdl2java goal specified, and I want to generate code for multiple services. I know you can specify a <serviceName>
under the <wsdlOption>
tag, but when I try to put more than one <serviceName>
, or even create another <wsdlOption>
using the same <wsdl>
value with a different <serviceName>
, it seems to ignore one of them and just generate the classes for one service.
The only way around this that I've found is to create another identical <execution>
block and just change the <serviceName>
. Am I doing something wrong, or is that the only way to do it? Here is the overall setup for one <execution>
(the paths and service names have been changed for privacy's sake):
<execution>
<id>generate-sources-a</id>
<phase>generate-sources</phase>
<configuration>
<encoding>UTF-8</encoding>
<defaultOptions>
<bindingFiles>
<bindingFile>binding.xjb</bindingFile>
</bindingFiles>
</defaultOptions>
<sourceRoot>${project.build.directory}/generated-sources</sourceRoot>
<wsdlRoot>${project.build.directory}/wsdl</wsdlRoot>
<includes>
<include>Path/To/WSDL/MyWSDL.wsdl</include>
</includes>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.build.directory}/wsdl/Path/To/WSDL/MyWSDL.wsdl</wsdl>
<serviceName>ServiceA</serviceName>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
I've tried both this:
<wsdlOptions>
<wsdlOption>
<wsdl>${project.build.directory}/wsdl/Path/To/WSDL/MyWSDL.wsdl</wsdl>
<serviceName>ServiceA</serviceName>
<serviceName>ServiceB</serviceName>
</wsdlOption>
</wsdlOptions>
...and this (used in Example 4 here http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html):
<wsdlOptions>
<wsdlOption>
<wsdl>${project.build.directory}/wsdl/Path/To/WSDL/MyWSDL.wsdl</wsdl>
<serviceName>ServiceA</serviceName>
</wsdlOption>
<wsdlOption>
<wsdl>${project.build.directory}/wsdl/Path/To/WSDL/MyWSDL.wsdl</wsdl>
<serviceName>ServiceB</serviceName>
</wsdlOption>
</wsdlOptions>
**Note that these services are from the same WSDL provided by our client.
Thanks in advance for the help!
CXF includes a Maven plugin which can generate java artifacts from WSDL. Here is a simple example: < plugin > < groupId >org.apache.cxf</ groupId > < artifactId >cxf-codegen-plugin</ artifactId >
There are many ways to generate Java classes from WSDL files – one of them is using the cxf-codegen-plugin, which comes from the Apache Maven CXF.
hykes. Compatible with IntelliJ IDEA (Ultimate, Community, Educational), WebStorm. GitHub | Issues | JetBrains. This plugin helps you to generate specific template code by create table statement or database .
Your last solution worked for me with below confi
cxf.version>3.4.0
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/wsdl1.wsdl</wsdl>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/wsdl2.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With