How to use namespace mapping in axis wsdl2java ant task for gradle


(Robert Riesener) #1

How can I add a namespace mapping to axis ant task in gradle?

I use the following gradle build:

dependencies {

axisGenAntTask “org.apache.axis:axis-ant:1.4”,

“org.apache.axis:axis:1.4”,

“org.apache.axis:axis-jaxrpc:1.4”,

“axis:axis-wsdl4j:1.5.1”,

“commons-codec:commons-codec:1.3”,

“commons-logging:commons-logging:1.1.1”,

“commons-discovery:commons-discovery:0.2” }

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 = “resources/service.wsdl”

ant.genClassesFromWSDL(

url: wsdlLocation,

output: “src/main/java”,

// TODO namespace mapping here?

) }

The formely used ant target was this:

<axis-wsdl2java url=“resources/enhancedCheckService.wsdl”

output="${project.gen}/src"

deployscope=“session”

serverSide=“false”

noWrapped=“true”

skeletonDeploy=“false”

verbose=“true”

typeMappingVersion=“1.2”

testcase=“no”>

<mapping namespace=“http://www.my.org/

package=“com.service.gen”/>

I can’t get the mapping tag to work in gradle.

The Wsdl2javaAntTask has an addMapping method with which holds the mapping details. How can I get this function called in the genClassesFromWSDL? Any ideas?


(Peter Niederwieser) #2

How would the Ant task declaration look like? The Gradle declaration should be a mechanical translation from that.


(Robert Riesener) #3

ant task is as follow:

<axis-wsdl2java url="resources/service.wsdl"
                        output="gen/src"
                        deployscope="session"
                        serverSide="false"
                        noWrapped="true"
                        skeletonDeploy="false"
                        verbose="true"
                        typeMappingVersion="1.2"
                        testcase="no">
            <mapping namespace="http://www.service.org/"
                     package="com.mypackage.runtime"/>
        </axis-wsdl2java>

(Peter Niederwieser) #4

This becomes:

ant.genClassesFromWSDL(url: wsdlLocation, output: "src/main/java", ...) {
    mapping(namespace: "http://www.service.org/", package: "com.mypackage.runtime")
  }

For more information, see the Ant chapter in the Gradle user guide.


(Robert Riesener) #5

Thank you Peter, works great!