Brandon
Brandon

Reputation: 6872

Example Java Client from WSDL generation using local wsdl file and bindings file and maven?

Does anyone know of a complete example of generating a Java Client from a local WSDL file that uses custom jaxb bindings and generated using maven (also, preferably for windows)?

Is wsimport or wsdl2java recommended for this task?

Upvotes: 2

Views: 2481

Answers (1)

Julien Sere
Julien Sere

Reputation: 69

The cxf-codegen-plugin should do the job.

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <executions>
        <execution>
        <id>generate-sources-composite</id>
        <phase>generate-sources</phase>
        <configuration>
            <sourceRoot>${basedir}/target/generated-sources/wsdl2java</sourceRoot>
            <defaultOptions>
            </defaultOptions>
            <wsdlOptions>
                <wsdlOption>
                    <wsdl>${basedir}/src/main/wsdl/service1.wsdl</wsdl>
                </wsdlOption>
                <wsdlOption>
                    <wsdl>${basedir}/src/main/wsdl/service2.wsdl</wsdl>
                </wsdlOption>
            </wsdlOptions>
        </configuration>
        <goals>
            <goal>wsdl2java</goal>
        </goals>
    </execution>
    </executions>
</plugin>

With this configuration, you just need to set the wsdl files and the java source generated folder (which should be in the target folder)

Upvotes: 3

Related Questions