glipecki / wsdl-gradle-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WSDL Gradle Plugin

Note
Version 3 of this plugin will only work with Gradle 6 and JDK 8.

Summary

This plugin generates Java code from WSDL files based on Apache Axis 1 (see http://axis.apache.org/axis/) or Apache Axis 2 (see http://axis.apache.org/axis2/java/core/).

Usage

To apply the WSDL Gradle Plugin to your projects, add the following in your build script:

Groovy
build.gradle
plugins {
    id 'com.intershop.gradle.wsdl' version '3.0.0'
}

wsdl {
    axis1 {
        genNameAxis1 {
            wsdlFile = file('staticfiles/wsdl/axis1File.wsdl')
            serverSide = true
            namespacePackageMappings {
                soap {
                    namespace = 'http://soapinterop.org/'
                    packageName = 'samples.axis1'
                }
                soapxsd {
                    namespace = 'http://soapinterop.org/xsd'
                    packageName = 'samples.axis1'
                }
            }
            // more parameters are possible
        }
    }
    axis2 {
        genNameAxis2 {
            wsdlFile = file('staticfiles/wsdl/axis2File.wsdl')
            serverSide = true
            allPorts = true
            serviceDescription = true
            packageName = 'samples.axis2'
            databindingMethod = 'none'
            // more parameters are possible
        }
    }

    // set special JVM configuration parameter for code generation tasks of Axis1
    tasks.withType(com.intershop.gradle.wsdl.tasks.axis1.WSDL2Java) {
        forkOptions { JavaForkOptions options ->
            options.setMaxHeapSize('64m')
            options.jvmArgs += ['-Dhttp.proxyHost=10.0.0.100', '-Dhttp.proxyPort=8800']
        }
    }

    tasks.withType(om.intershop.gradle.wsdl.tasks.axis2.WSDL2Java) {
        forkOptions { JavaForkOptions options ->
            options.setMaxHeapSize('64m')
            options.jvmArgs += ['-Dhttp.proxyHost=10.0.0.100', '-Dhttp.proxyPort=8800']
        }
    }
Kotlin
build.gradle.kts
plugins {
    id("com.intershop.gradle.wsdl") version "3.0.0"
}

wsdl {
    axis1 {
        register("genNameAxis1") {
            wsdlFile = file("staticfiles/wsdl/axis1File.wsdl")
            serverSide = true
            namespacePackageMappings {
                soap {
                    namespace = "http://soapinterop.org/"
                    packageName = "samples.axis1"
                }
                soapxsd {
                    namespace = "http://soapinterop.org/xsd"
                    packageName = "samples.axis1"
                }
            }
            // more parameters are possible
        }
    }
    axis2 {
        register("genNameAxis2") {
            wsdlFile = file("staticfiles/wsdl/axis2File.wsdl")
            serverSide = true
            allPorts = true
            serviceDescription = true
            packageName = "samples.axis2"
            databindingMethod = "none"
            // more parameters are possible
        }
    }

    // set special JVM configuration parameter for code generation tasks of Axis1
    tasks.withType(com.intershop.gradle.wsdl.tasks.axis1.WSDL2Java::class.java) {
        forkOptions {
            maxHeapSize = "64m"
            systemProperty("http.proxyHost", "10.0.0.100")
            systemProperty("http.proxyPort", "8800")
        }
    }

    tasks.withType(om.intershop.gradle.wsdl.tasks.axis2.WSDL2Java::class.java) {
        forkOptions {
            maxHeapSize = "64m"
            systemProperty("http.proxyHost", "10.0.0.100")
            systemProperty("http.proxyPort", "8800")
        }
    }
}

If the JavaBasePlugin is applied to the project, generated java sources will be added to the specified source set. Per default the main source set is used.

Important
This plugin uses the version 1.4 of Axis 1 and 1.7.7 of Axis 2. It is possible to change or extend the configuration with special configurations.

Tasks

The WSDL Gradle plugin adds one task wsdl2java to the project. A special task is added for each configuration. The task wsdl2java depends on all other tasks.

Task name

Type

Description

wsdl2java

Task

Overall wsdl2java code generation task of a project. This task depends on all axis1Wsdl2java and axis2Wsdl2java tasks.

axis1Wsdl2java<name>

com.intershop.gradle.wsdl.tasks.axis1.WSDL2Java

This task generates Java code from WSDL file using Axis 1.

axis2Wsdl2java<name>

com.intershop.gradle.wsdl.tasks.axis2.WSDL2Java

This task generates Java code from WSDL file using Axis 2.

Project Extension 'wsdl'

This plugin adds an extension wsdl to the project.

Methods

Method Values Description

axis1

axis1

This contains all code generation configurations for Axis 1.

axis2

axis2

This contains all code generation configurations for Axis 2.

Object 'axis1' (com.intershop.gradle.wsdl.extension.Axis1)

Properties

Property

Type

Default value

Description

noImports

boolean

false

Only generate code for the WSDL document that appears on the command line if this value is true. The default behaviour is to generate files for all WSDL documents, the immediate one and all imported ones.
WSDL2Java Parameter: -n, --noImports

timeout

int

240

Timeout in seconds. The default is 240. Use -1 to disable the timeout.
WSDL2Java Parameter: -O, --timeout

noWrapped

boolean

false

If this value is true, it turns off the special treatment of what is called "wrapped" document/literal style operations. By default, WSDL2Java will recognize the following conditions:
- If an input message has is a single part.
- The part is an element.
- The element has the same name as the operation
- The element’s complex type has no attributes
If this value is true, WSDL2Java will 'unwrap' the top level element, and treat each of the components of the element as arguments to the operation. This type of WSDL is the default for Microsoft .NET web services, which wrap up RPC style arguments in this top level schema element.
WSDL2Java Parameter: -W, --noWrapped

serverSide

boolean

false

Emit the server-side bindings for the web service.
WSDL2Java Parameter: -s, --server-side

skeletonDeploy

String

""

If this property is defined, the parameter is added. If deploy skeleton (true) or implementation (false) in deploy.wsdd.
Default is an empty string. Assumes server-side="true". WSDL2Java Parameter: -S, --skeletonDeploy <true

false>

deployScope

String

Add scope to deploy.wsdd:
- APPLICATION → "Application",
- REQUEST → "Request", or
- SESSION → "Session".
If this option does not appear, no scope tag appears in deploy.wsdd, which the Axis runtime defaults to "Request".
WSDL2Java Parameter: -d, --deployScope

generateAllClasses

boolean

false

Generate code for all elements, even unreferenced ones. By default, WSDL2Java only generates code for those elements in the WSDL file that are referenced.
WSDL2Java Parameter: -a, --all

typeMappingVersion

String

1.2

Indicate 1.1 or 1.2. The default is 1.2 (SOAP 1.2 JAX-RPC compliant).
WSDL2Java Parameter: -T, --typeMappingVersion

factory

String

Used to extend the functionality of the WSDL2Java emitter. The argument is the name of a class which extends JavaWriterFactory.
WSDL2Java Parameter: -F, --factory

helperGen

boolean

false

Emits separate Helper classes for meta data.
WSDL2Java Parameter: -H, --helperGen

userName

String

This username is used in resolving the WSDL-URI provided as the input to WSDL2Java.
If the URI contains a username, this will override the command line switch. An example of a URL with a username and password is: http://user:password@hostname:port/path/to/service?WSDL
WSDL2Java Parameter: -U, --user

password

String

This password is used in resolving the WSDL-URI provided as the input to WSDL2Java.
If the URI contains a password, this will override the command line switch.
WSDL2Java Parameter: -P, --password

implementationClassName

String

Set the name of the implementation class. Especially useful when exporting an existing class as a web service using java2wsdl followed by wsdl2java. If you are using the skeleton deploy option you must make sure, after generation, that your implementation class implements the port type name interface generated by wsdl2java. You should also make sure that all your exported methods throws java.lang.RemoteException.
WSDL2Java Parameter: -c, --implementationClassName

wrapArrays

boolean

false

Prefer generating JavaBean classes like "ArrayOfString" for certain schema array patterns (default is to use String [])
WSDL2Java Parameter: -w, --wrapArrays

allowInvalidURL

boolean

false

This flag is used to allow Stub generation even if WSDL endpoint URL is not a valid URL. It’s the responsibility of the user to update the endpoint value before using generated classes.
WSDL2Java Parameter: --allowInvalidURL

sourceSetName

String

main

Name of the source set for generated Java code default value is 'main'

packageName

String

This is a shorthand option to map all namespaces in a WSDL document to the same Java package name. This can be useful, but dangerous. You must make sure that you understand the effects of doing this. For instance there may be multiple types with the same name in different namespaces. It is an error to use the --NStoPkg switch and --package at the same time.
WSDL2Java Parameter: -p, --package

namespacePackageMappings

NamedDomainObjectContainer<NamespacePackageMapping>

By default, package names are generated from the namespace strings in the WSDL document in a magical manner (typically, if the namespace is of the form "http://x.y.com" or "urn:x.y.com" the corresponding package will be "com.y.x"). If this magic is not what you want, you can provide your own mapping using the this maps argument. For example, if there is a namespace in the WSDL document called "urn:AddressFetcher2", and you want files generated from the objects within this namespace to reside in the package samples.addr.
WSDL2Java Parameter: -N, --NStoPkg

generateTestcase

boolean

false

Generate a client-side JUnit test case. This test case can stand on its own, but it doesn’t really do anything except pass default values (null for objects, 0 or false for primitive types). Like the generated implementation file, the generated test case file could be considered a template that you may fill in.
WSDL2Java Parameter: -t, --testCase

namespacePackageMappingFile

File

If there are a number of namespaces in the WSDL document, listing a mapping for them all could become tedious. To help keep the command line terse, WSDL2Java will also look for mappings in a properties file. By default, this file is named "NStoPkg.properties" and it must reside in the default package (ie., no package). But you can explicitly provide your own file using this option. The entries in this file are of the same form as the arguments to the namespacePackageMapping option. For example, instead of providing the command line option as above, we could provide the same information in a properties file: urn\:AddressFetcher2=samples.addr (Note that the colon must be escaped in the properties file.) If an entry for a given mapping exists both with namespacePackageMapping and in this properties file, the namespacePackageMapping entry takes precedence.
WSDL2Java Parameter: -f, --fileNStoPkg

nsInclude

String

Namescape to specifically include in the generated code (defaults to all namespaces unless specifically excluded with the nsExclude option)
WSDL2Java Parameter: -i, --nsInclude

nsExclude

String

Namespace to specifically exclude from the generated code (defaults to none excluded until first namespace included with nsInclude option)
WSDL2Java Parameter: -x, --nsExclude

properties

Map<String, String>

Names and values of a properties for use by the custom GeneratorFactory
WSDL2Java Parameter: -p, --property

outputDir

File

Output directory for emitted files
WSDL2Java Parameter: -o, --output

wsdlProperties

NamedDomainObjectContainer<WSDLProperty>

List of additional properties for WSDL2Java command line tool.
WSDL2Java Parameter: --property

args

List<String>

List of additional arguments for WSDL2Java command line tool.

wsdlFile

File

The default output dir is <project build dir>/generated/wsdl2java/axis1/<configuration name>

Methods

Method

Parameter

Description

addAarg

String

Add an additional command line argument passed to the WSDL2Java command

addAargs

List<String>

Add additional command line arguments passed to the WSDL2Java command

Object 'axis2' (com.intershop.gradle.wsdl.extension.Axis2)

Properties

Property

Type

Default value

Description

async

boolean

false

Generate code only for async style. When this option is used the generated stubs will have only the asynchronous invocation methods. Switched off by default.
WSDL2Java Parameter: -a, --async

sync

boolean

false

Generate code only for sync style. When this option is used the generated stubs will have only the synchronous invocation methods. Switched off by default. When async is set to true, this takes precedence.
WSDL2Java Parameter: -s, --sync

serverSide

boolean

false

Generates server side code (i.e. skeletons).
WSDL2Java Parameter: -ss, --server-side

serviceDescription

boolean

false

Generates the service descriptor (i.e. server.xml). Default is false. + Only valid if serverSide is true, the server side code generation option.
WSDL2Java Parameter: -sd, --service-description

databindingMethod

String

adb

Specifies the Databinding framework. Valid values are
- xmlbeans → XMLBEANS,
- adb → ADB,
- jibx → JIBX, and
- none → NONE.
WSDL2Java Parameter: -d , --databinding-method

generateAllClasses

boolean

false

Generates all the classes. This option is valid only if serverSide otpion is true. If the value is true, the client code (stubs) will also be generated along with the skeleton.
WSDL2Java Parameter: -g, --generate-all

unpackClasses

boolean

false

Unpack classes. This option specifies whether to unpack the classes and generate separate classes for the databinders.
WSDL2Java Parameter: -u, --unpack-classes

serviceName

String

Specifies the service name to be code generated. If the service name is not specified, then the first service will be picked.
WSDL2Java Parameter: -sn, --service-name

portName

String

Specifies the port name to be code generated. If the port name is not specified, then the first port (of the selected service) will be picked.
WSDL2Java Parameter: -pn, --port-name

serversideInterface

boolean

false

Generate an interface for the service skeleton.
WSDL2Java Parameter: -ssi, --serverside-interface

wsdlVersion

String

WSDL Version. Valid Options : 2, 2.0, 1.1
WSDL2Java Parameter: -wv, --wsdl-version

flattenFiles

boolean

false

Flattens the generated files if true
WSDL2Java Parameter: -f, --flatten-files

unwrapParams

boolean

false

Switch on un-wrapping, if this value is true.
WSDL2Java Parameter: -uw, --unwrap-params

xsdconfig

boolean

false

Use XMLBeans .xsdconfig file if this value is true. This is only valid if databindingMethod is 'xmlbeans'.
WSDL2Java Parameter: -xsdconfig

allPorts

boolean

false

Generate code for all ports
WSDL2Java Parameter: -ap, --all-ports

backwordCompatible

boolean

false

Generate Axis 1.x backword compatible code
WSDL2Java Parameter: -b, --backword-compatible

suppressPrefixes

boolean

false

Suppress namespace prefixes (Optimzation that reduces size of soap request/response)
WSDL2Java Parameter: -sp, --suppress-prefixes

noMessageReceiver

boolean

false

Don’t generate a MessageReceiver in the generated sources
WSDL2Java Parameter: --noMessageReceiver

sourceSetName

String

main

Name of the source set for generated Java code default value is 'main'

packageName

String

The target package name. If omitted, a default package (formed using the target namespace of the WSDL) will be used.
WSDL2Java Parameter: -p, --package

namespacePackageMappings

NamedDomainObjectContainer<NamespacePackageMapping>

Specifies a comma separated list of namespaces and packages where the given package will be used in the place of the auto generated package for the relevant namespace. The list will be the format of ns1=pkg1,ns2=pkg2.
WSDL2Java Parameter: -ns2p, --namespace2package

generateTestcase

boolean

false

Generates a test case. In the case of Java it would be a JUnit test case.
WSDL2Java Parameter: -t, --test-case

namespacePackageMappingFile

File

Specify an external mapping file
WSDL2Java Parameter: -em, --external-mapping

outputDir

File

Output file location. This is where the files would be copied once the code generation is done. If this option is omitted the generated files would be copied to the working directory.
WSDL2Java Parameter: -o, --output

args

List<String>

List of additional arguments for WSDL2Java command line tool.

wsdlFile

File

Input WSDL file

The default output dir is <project build dir>/generated/wsdl2java/axis2/<configuration name>

Methods

Method

Parameter

Description

addAarg

String

Add an additional command line argument passed to the WSDL2Java command

addAargs

List<String>

Add additional command line arguments passed to the WSDL2Java command

WSDL2Java Command Line Tool / Additonal Java VM configuration

The code generator task uses the WSDL2Java commandline tool of Axis 1 or Axis 2. It is possible to add additional environment variables to these JVM. See main example.

Version Configuration for WSDL2Java tasks

This plugin adds two configurations wsdlAxis1 for Axis 1 and wsdlAxis2 for Axis 2. These dependencies are used for the classpath of WSDL command line tool.

Axis 1

The base configuration uses dependencies of Axis 1 with version 1.4.

build.gradle
'axis:axis-wsdl4j:1.5.1'
'commons-discovery:commons-discovery:0.5'
'javax.activation:activation:1.1.1'
'javax.mail:mail:1.4.7'
'commons-logging:commons-logging:1.2'
'org.apache.axis:axis:1.4'
'org.apache.axis:axis-jaxrpc:1.4'

It is possible to change the configuration / version of the used dependencies.

Axis 2

The base configuration uses dependencies of Axis 1 with version 1.7.7

build.gradle
'org.apache.axis2:axis2-kernel:1.7.7'
'org.apache.axis2:axis2-codegen:1.7.7'
'org.apache.axis2:axis2-adb:1.7.7'
'org.apache.axis2:axis2-adb-codegen:1.7.7'
'org.apache.axis2:axis2-jaxbri:1.7.7'
'com.sun.xml.ws:jaxws-tools:2.2.10'
'wsdl4j:wsdl4j:1.6.3'
'commons-logging:commons-logging:1.2'
'org.apache.neethi:neethi:3.0.3'
'org.apache.ws.commons.axiom:axiom-api:1.2.20'
'org.apache.ws.commons.axiom:axiom-impl:1.2.20'
'org.apache.woden:woden-core:1.0M10'
'org.apache.ws.xmlschema:xmlschema-core:2.2.1'
'com.sun.xml.bind:jaxb-impl:2.2.6'
'com.sun.xml.bind:jaxb-xjc:2.2.6'

It is possible to change the configuration or version of the used dependencies. This configuration is used for a different databinding 'XMLBeans'.

build.gradle
    configurations {
        wsdlAxis2.extendsFrom(compile)
    }

    dependencies {
        wsdlAxis2 'org.apache.axis2:axis2-codegen:1.7.3'
        wsdlAxis2 'wsdl4j:wsdl4j:1.6.3'
        wsdlAxis2 'commons-logging:commons-logging:1.2'
        wsdlAxis2 'org.apache.neethi:neethi:3.0.3'
        wsdlAxis2 'org.apache.ws.commons.axiom:axiom-api:1.2.20'
        wsdlAxis2 'org.apache.ws.commons.axiom:axiom-impl:1.2.20'
        wsdlAxis2 'org.apache.woden:woden-core:1.0M10'
        wsdlAxis2 'org.apache.ws.xmlschema:xmlschema-core:2.2.1'
    }

License

Copyright 2014-2018 Intershop Communications.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

License:Apache License 2.0


Languages

Language:Kotlin 70.5%Language:Groovy 29.5%