Evan LaHurd
Evan LaHurd

Reputation: 977

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!

Upvotes: 8

Views: 2119

Answers (1)

sabri
sabri

Reputation: 36

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>

Upvotes: 1

Related Questions