Generate WSDL document from Java

If the WSDL served by your service at http://your-host/your-service?wsdl is not enough because you e.g. want to distribute it as a Maven artifact, then you can use java2ws to generate the WSDL document at build time.

You do not need to invoke the java2ws tool provided by CXF directly, neither you have to use the cxf-java2ws-plugin.

quarkus-cxf wraps java2ws and so you can configure it in application.properties as any other aspect of your application.

Here is an example:

The sample code snippets used in this section come from the server integration test in the source tree of CXF Extensions for Quarkus
application.properties
quarkus.cxf.java2ws.includes=io.quarkiverse.cxf.it.server.HelloService,io.quarkiverse.cxf.it.server.FaultyHelloService
quarkus.cxf.java2ws.wsdl-name-template=%TARGET_DIR%/Java2wsTest/%SIMPLE_CLASS_NAME%-from-java2ws.wsdl

Here we have instructed java2ws to generate WSDLs for two interfaces, namely HelloService and FaultyHelloService.

Note that the Service interfaces must be annotated with jakarta.xml.ws.WebService to be selected for java2ws processing.

The two generated WSDL documents will be stored as target/Java2wsTest/FaultyHelloService-from-java2ws.wsdl and target/Java2wsTest/HelloService-from-java2ws.wsdl respectively.

Unlike wsdl2java which is executed within Quarkus source generation phase, java2ws is a part Quarkus augmentation that happens after compilation. The input of java2ws are, after all, Java class files. Hence you do not need to add <goal>generate-code</goal> to quarkus-maven-plugin for java2ws.

See also