Groovy & Gradle Scripts to Generate Java classes for a wsdl of a php5 app using axis 1.4
daniel Wed, 02/09/2011 - 11:30am
UPDATE at bowerstudios
Had to consume the SOAP service of a php5 app, and it was a bear.
Ended up using Axis (The First Version) since the wsdl was rpc-encoded, and I was unable to get the Groovy-WS plugin working with it.
Here is a nice self contained groovy script to generate java classes for a wsdl
@Grab(group='axis', module='axis', version='1.4')
import org.apache.axis.wsdl.WSDL2Java
class Generator {
static def generate(){
WSDL2Java.main("http://localhost/myservice.wsdl")
}
}
Generator.generate()
Or, add a task to Gradle:
In build.gradle
Add to Configurations:
configurations {
compile
runtime
axisGenAntTask
}
Then add this dependency:
axisGenAntTask 'axis:axis-ant:1.4', 'axis:axis:1.4'
Finally, add the Task:
task genWsdlClasses() << {
ant.echo(message:'Generating Classes for use with WSDL')
ant.taskdef(
name: 'genClassesFromWSDL',
classname: 'org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask',
classpath: configurations.axisGenAntTask.asPath
)
def wsdlLocation = 'http://localhost/myservice.wsdl'
ant.genClassesFromWSDL(
url: wsdlLocation,
output: 'src/main/java'
)
}
- Log in to post comments