Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate sources for multiple services using Apache CXF codegen plugin for Maven under one execution

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!

like image 991
Evan LaHurd Avatar asked Aug 31 '15 18:08

Evan LaHurd


People also ask

What is CXF codegen plugin?

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 >

Which CXF plugin can be used to generate the Java stubs?

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.

What is codegen plugin?

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 .


1 Answers

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>
like image 166
sabri Avatar answered Oct 13 '22 21:10

sabri