In this post we will see an example on generating stubs from multiple QSDL files using Maven or Gradle plugin. Let’s say, you are given a WSDL file and you want to generate Java class from it, then you need to do some configurations in your maven or gradle project to automate the activities.

You can also generate using command from command line but using maven or gradle configurations it will be easier to manage.


Java, Maven or Gradle


Using Maven Configuration

If you have maven based project then you can use below maven based plugin to generate stubs or Java classes from the WSDL file.

							<wsdlOption>                                                                                                                   	<wsdl>${basedir}/src/main/resources/wsdl/<wsdl1>.wsdl</wsdl>
								<!-- if you want to use URL -->
								<!-- <wsdl>http://<host>:<port>/<name1>.wsdl</wsdl> -->
							<wsdlOption>                                                                                                               		<wsdl>${basedir}/src/main/resources/wsdl/<wsdl2>.wsdl</wsdl>
								<!-- if you want to use URL -->
								<!-- <wsdl>http://<host>:<port>/<name2>.wsdl</wsdl> -->

Using Gradle Configurations

If you have gradle based project then you can use below gradle based plugin to generate stubs or Java classes from WSDL file.

buildscript {
    repositories {
    dependencies {
		classpath 'no.nils:wsdl2java:0.10'
apply plugin: 'java'
apply plugin: 'no.nils.wsdl2java'
wsdl2javaExt {
	cxfVersion = "3.1.10"
	generatedWsdlDir = file("${projectDir}/src/main/service") //java source classes will be generated
	wsdlDir=file("${projectDir}/src/main/resources/wsdl/") //wsdl directory
	wsdlsToGenerate = [
		[file("${projectDir}/src/main/resources/wsdl/wsdl1.wsdl")], //wsdl1
		[file("${projectDir}/src/main/resources/wsdl/wsdl2.wsdl")], //wsdl2
		[file("${projectDir}/src/main/resources/wsdl/wsdl3.wsdl")]  //wsdl3
compileJava.dependsOn wsdl2java

If you are using plugin com.github.bjornvester.wsdl2java, then you can use below build.gradle script.

Note that the default directory for the WSDL files is src/main/resources and Java classes will be generated under build/generated/wsdl2java directory.

plugins {
    id 'java-library'
    id "com.github.bjornvester.wsdl2java" version "0.2"
sourceCompatibility = 12
targetCompatibility = 12
repositories {
    maven {
		url ''
dependencies {
	implementation ''
	implementation 'org.glassfish.jaxb:txw2:2.4.0-b180608.0325'
wsdl2java {

That’s all. Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *