Skip to content

Worker API

CAUTION

The Worker API approach is an incubating feature and is subject to change in future releases.

The Worker API approach uses Gradle's Worker API to execute the wsdl2java tool in isolation. Configuration options represent the unit of work submitted to Gradle's Worker API. This allows Gradle to parallelize the work, fully utilize resources available on the host machine, and complete builds faster.

Enablement

The Worker API approach is not enabled by default since it is an incubating feature.

To enable it, set theio.mateo.cxf-codegen.workers Gradle property to true.

This can be accomplished in several ways such as configuring it in the gradle.properties file or passing it as a command-line argument when invoking Gradle. The properties file approach is shown below.

properties
io.mateo.cxf-codegen.workers=true

Configuration

For each WSDL document to process, create an option that holds the configuration for that unit of work. The option should be an instance of Wsdl2JavaOption.

To create an option, use the options container through the cxfCodegen extension.

The following example shows a single option named example that processes the example.wsdl document:

kotlin
import io.mateo.cxf.codegen.workers.Wsdl2JavaOption

// ...

cxfCodegen {
    options {
        register<Wsdl2JavaOption>("example") {
            wsdl = file("src/main/resources/wsdl/example.wsdl").absolutePath
        }
    }
}
groovy
import io.mateo.cxf.codegen.workers.Wsdl2JavaOption

// ...

cxfCodegen {
    options {
        register("example", Wsdl2JavaOption) {
            wsdl = file("src/main/resources/wsdl/example.wsdl").absolutePath
        }
    }
}

By convention, the generated Java sources will be created in the$buildDir/$name-wsdl2java-generated-sources directory where $name is the option name.

Add to main Source Set

The generated Java code is automatically added to the main source set. This means that the generated code will be available for use in your project's application code, typically located in the src/main/java directory.

If you do not want the generated code to be added to the main source set, you can set the addToMainSourceSet property to false as shown below:

kotlin
cxfCodegen {
    addToMainSourceSet = false
}
groovy
cxfCodegen {
    addToMainSourceSet = false
}

Tool Options

The Wsdl2JavaOption type provides type-safe properties that map to the underlying wsdl2java tool options. The properties are all lazy properties. Their values are realized when the task is executed.

The table below lists the available properties, descriptions, and type. These are a direct mapping to the wsdl2java tool options listed in the tool's documentation here.

TypeNameDescription
Property<String>wsdlThe WSDL to process. The value can either be a direct path to a file on a local system or URL to a remote file.
DirectoryPropertyoutputDirectorySpecifies the directory the generated code files are written. If not set, the convention is build/$name-wsdl2java-generated-sources. The $name variable is the option name
ListProperty<String>packageNamesSpecifies zero, or more, package names to use for the generated code. Optionally specifies the WSDL namespace to package name mapping.
ListProperty<String>extraArgsSpecifies extra arguments to pass to the command-line code generator.
ListProperty<String>xjcArgsSpecifies arguments that are passed directly to the XJC processor when using the JAXB data binding.
ListProperty<String>asyncMethodsSpecifies subsequently generated Java class methods to allow for client-side asynchronous calls, similar to enableAsyncMapping in a JAX-WS binding file.
ListProperty<String>bareMethodsSpecifies subsequently generated Java class methods to have wrapper style, similar to enableWrapperStyle in JAX-WS binding file.
ListProperty<String>mimeMethodsSpecifies subsequently generated Java class methods to enable mime:content mapping, similar to enableMIMEContent in JAX-WS binding file.
ListProperty<String>namespaceExcludesIgnore the specified WSDL schema namespace when generating code. Optionally specifies the Java package name used by types described in the excluded namespace(s) using schema-namespace[=java-packagename].
Property<Boolean>defaultExcludesNamespaceEnables or disables the loading of the default excludes namespace mapping. If not set, wsdl2java defaults to true.
Property<Boolean>defaultNamespacePackageMappingEnables or disables the loading of the default namespace package name mapping. If not set, wsdl2java defaults to true and the http://www.w3.org/2005/08/addressing package mapping will be enabled.
SetProperty<String>bindingFilesSpecifies JAX-WS or JAXB binding files or XMLBeans context files. The values are evaluated as per Directory#file(String) from ProjectLayout#getProjectDirectory().
Property<String>wsdlLocationSpecifies the value of the @WebServiceClient annotation's wsdlLocation property. By default, the wsdl2java tool will use the value of wsdl.
Property<Boolean>wsdlListSpecifies that the wsdlurl contains a plain text, new line delimited, list of wsdlurls instead of the WSDL itself.
Property<String>frontendSpecifies the frontend. Currently only supports JAX-WS CXF frontends and a jaxws21 frontend to generate JAX-WS 2.1 compliant code. If not set, wsdl2java defaults to jaxws.
Property<String>databindingSpecifies the databinding. Currently, supports JAXB, XMLBeans, SDO (sdo-static and sdo-dynamic), and JiBX. If not set, wsdl2java defaults to jaxb.
Property<String>wsdlVersionSpecifies the WSDL version. If not set, wsdl2java defaults to WSDL1.1; currently supports only WSDL1.1 version.
Property<String>catalogSpecify catalog file to map the imported WSDL/schema.
Property<Boolean>extendedSoapHeadersEnables or disables processing of implicit SOAP headers (i.e. SOAP headers defined in the wsdl:binding, but not wsdl:portType section). If not set, wsdl2java defaults to false.
Property<String>validateWsdlEnables validating the WSDL before generating the code.
Property<Boolean>noTypesEnables or disables generation of the type classes. If not set, wsdl2java defaults to false.
Property<String>faultSerialVersionUidSpecifies how to generate serial version UID of fault exceptions. Use one of the following: NONE, TIMESTAMP, FQCN, or a specific number. If not set, wsdl2java defaults to NONE.
Property<String>exceptionSuperSpecifies the superclass for fault beans generated from wsdl:fault elements. If not set, wsdl2java defaults to Exception.
ListProperty<String>seiSuperSpecifies the superinterfaces to use for generated SEIs.
Property<Boolean>markGeneratedEnables or disables adding the @Generated annotation to classes generated.
Property<Boolean>suppressGeneratedDateEnables or disables writing the current timestamp in the generated file (since CXF version 3.2.2).
Property<String>serviceNameSpecifies the WSDL service name to use for the generated code.
Property<Boolean>autoNameResolutionEnables or disables automatically resolving naming conflicts without requiring the use of binding customizations.
Property<Boolean>noAddressBindingFor compatibility with CXF 2.0, this flag directs the code generator to generate the older CXF proprietary WS-Addressing types instead of the JAX-WS 2.1 compliant WS-Addressing types.
Property<Boolean>allowElementRefsEnables or disables disregarding the rule given in section 2.3.1.2(v) of the JAX-WS 2.2 specification disallowing element references when using wrapper-style mapping.
Property<String>encodingEncoding to use for generated sources (since CXF version 2.5.4).
Property<Boolean>verboseEnables or disables verbosity.

Logging

The wsdl2java tool's logging output can be viewed when executing Gradle with the -d/--debug flag. This will show the logging output from the tool in the console. The tool logs at the FINE level, so the debug flag is required to see the output.

2026-04-18T18:15:04.136-0500 [DEBUG] [org.apache.cxf.common.logging.LogUtils] Using org.apache.cxf.common.logging.Slf4jLogger for logging.
2026-04-18T18:15:04.138-0500 [DEBUG] [jakarta.xml.bind] Resolved classes from context path: [class org.apache.cxf.tools.plugin.ObjectFactory]
2026-04-18T18:15:04.138-0500 [DEBUG] [jakarta.xml.bind] Checking system property jakarta.xml.bind.JAXBContextFactory
2026-04-18T18:15:04.138-0500 [DEBUG] [jakarta.xml.bind]   not found
2026-04-18T18:15:04.139-0500 [DEBUG] [jakarta.xml.bind] ServiceProvider loading Facility used; returning object [org.glassfish.jaxb.runtime.v2.JAXBContextFactory]
2026-04-18T18:15:04.139-0500 [DEBUG] [jakarta.xml.bind] Using jakarta.xml.bind-api on the class path.
2026-04-18T18:15:04.142-0500 [DEBUG] [org.glassfish.jaxb.runtime.v2.ContextFactory] Property org.glassfish.jaxb.XmlAccessorFactoryis not active.  Using JAXB's implementation
2026-04-18T18:15:04.186-0500 [DEBUG] [org.apache.cxf.tools.wsdlto.core.PluginLoader] Loading plugin jar:file:/Users/example/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-tools-wsdlto-databinding-jaxb/4.1.3/.../cxf-tools-wsdlto-databinding-jaxb-4.1.3.jar!/META-INF/tools-plugin.xml
2026-04-18T18:15:04.234-0500 [DEBUG] [org.apache.cxf.tools.wsdlto.core.PluginLoader] Found 1 databindings in <jaxb> plugin.
2026-04-18T18:15:04.234-0500 [DEBUG] [org.apache.cxf.tools.wsdlto.core.PluginLoader] Loading <jaxb> databinding from <jaxb> plugin.
2026-04-18T18:15:04.234-0500 [DEBUG] [org.apache.cxf.tools.wsdlto.core.PluginLoader] Loading plugin jar:file:/Users/example/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-tools-wsdlto-frontend-jaxws/4.1.3/.../cxf-tools-wsdlto-frontend-jaxws-4.1.3.jar!/META-INF/tools-plugin.xml

...and so on

Released under Apache 2.0 license