Generate the Model classes from WSDL
quarkus-cxf extension supports generating Java classes from WSDL during Quarkus code generation phase.
|The code snippets shown in this section come from the client integration test in the source tree of CXF Extensions for Quarkus. You may want to check it as an executable example.|
You need to set up a couple of things for CXF code generation to work:
io.quarkiverse.cxf:quarkus-cxfdependency in your project
For Maven projects, the
generate-codegoal needs to be present in the configuration of
<plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <executions> <execution> <goals> <goal>build</goal> <goal>generate-code</goal> </goals> </execution> </executions> </plugin>
For Gradle projects no additional configurarion of
io.quarkusplugin is needed
Put your WSDL files under
src/test/resourcesor any subdirectory thereof.
Your WSDL file names must end with
quarkus.cxf.codegen.wsdl2java.includesconfiguration property to a pattern matching the WSDL files you wish to process. If you want to process all WSDL files under
src/test/resources/wsdl, set it as follows:application.properties
quarkus.cxf.codegen.wsdl2java.includes = wsdl/*.wsdl
This will generate Java classes in
They will be automatically picked by the compiler plugin there.
Hence we are free to refer to them from our application or test code.
quarkus-cxf code generation uses the wsdl2Java utility
from CXF under the hood.
wsdl2Java is called separately for each WSDL file selected by
Passing custom parameters to
wsdl2java is possible through
If you need different
additional-params for each WSDL file, you may want to define a separate named parameter set for
each one of them. Here is an example:
# Parameters for foo.wsdl quarkus.cxf.codegen.wsdl2java.foo-params.includes = wsdl/foo.wsdl quarkus.cxf.codegen.wsdl2java.foo-params.additional-params = -wsdlLocation,wsdl/foo.wsdl # Parameters for bar.wsdl quarkus.cxf.codegen.wsdl2java.bar-params.includes = wsdl/bar.wsdl quarkus.cxf.codegen.wsdl2java.bar-params.additional-params = -wsdlLocation,wsdl/bar.wsdl,-xjc-Xts