This tutorial may be useful when you want to generate stubs from multiple WSDL files using maven or gradle plugin.

Use below maven based plugin to generate stubs

...

<build>
	<plugins>
		<plugin>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-codegen-plugin</artifactId>
			<version>3.1.10</version>
			<executions>
				<execution>
					<id>generate-sources</id>
					<phase>generate-sources</phase>
					<configuration>
						<sourceRoot>${basedir}/src/main/java</sourceRoot>
						<wsdlOptions>
							<wsdlOption>                                                                                                                                <wsdl>${basedir}/src/main/resources/wsdl/<wsdl1>.wsdl</wsdl>
								<!-- if you want to use URL -->
								<!-- <wsdl>http://<host>:<port>/<name1>.wsdl</wsdl> -->
							</wsdlOption>
							<wsdlOption>                                                                                                                                <wsdl>${basedir}/src/main/resources/wsdl/<wsdl2>.wsdl</wsdl>
								<!-- if you want to use URL -->
								<!-- <wsdl>http://<host>:<port>/<name2>.wsdl</wsdl> -->
							</wsdlOption>
						</wsdlOptions>
					</configuration>
					<goals>
						<goal>wsdl2java</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

Use below gradle based plugin to generate stubs

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
		classpath 'no.nils:wsdl2java:0.10'
    }
}

apply plugin: 'java'
apply plugin: 'no.nils.wsdl2java'

wsdl2javaExt {
	cxfVersion = "3.1.10"
}

wsdl2java{
	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

...

Thanks for reading.

I am a professional Web developer, Enterprise Application developer, Software Engineer and Blogger. Connect me on Roy Tutorials Twitter Facebook  Google Plus Linkedin Or Email Me

Leave a Reply

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