Note
|
Version 3 of this plugin will only work with Gradle 6 and JDK 8. |
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/).
To apply the WSDL Gradle Plugin to your projects, add the following in your build script:
Groovy
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
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. |
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 |
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. |
This plugin adds an extension wsdl
to the project.
Method | Values | Description |
---|---|---|
axis1 |
This contains all code generation configurations for Axis 1. |
|
axis2 |
This contains all code generation configurations for Axis 2. |
Property |
Type |
Default value |
Description |
noImports |
|
|
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. |
timeout |
|
|
Timeout in seconds. The default is 240. Use -1 to disable the timeout. |
noWrapped |
|
|
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: |
serverSide |
|
|
Emit the server-side bindings for the web service. |
skeletonDeploy |
|
|
If this property is defined, the parameter is added. If deploy skeleton (true) or implementation (false) in deploy.wsdd. |
false> |
deployScope |
|
|
Add scope to deploy.wsdd: |
generateAllClasses |
|
|
Generate code for all elements, even unreferenced ones. By default, WSDL2Java only generates code for those elements in the WSDL file that are referenced. |
typeMappingVersion |
|
|
Indicate 1.1 or 1.2. The default is 1.2 (SOAP 1.2 JAX-RPC compliant). |
factory |
|
|
Used to extend the functionality of the WSDL2Java emitter. The argument is the name of a class which extends JavaWriterFactory. |
helperGen |
|
|
Emits separate Helper classes for meta data. |
userName |
|
|
This username is used in resolving the WSDL-URI provided as the input to WSDL2Java. |
password |
|
|
This password is used in resolving the WSDL-URI provided as the input to WSDL2Java. |
implementationClassName |
|
|
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. |
wrapArrays |
|
|
Prefer generating JavaBean classes like "ArrayOfString" for certain schema array patterns (default is to use String []) |
allowInvalidURL |
|
|
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. |
sourceSetName |
|
|
Name of the source set for generated Java code default value is 'main' |
packageName |
|
|
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. |
namespacePackageMappings |
|
|
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. |
generateTestcase |
|
|
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. |
namespacePackageMappingFile |
|
|
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. |
nsInclude |
|
|
Namescape to specifically include in the generated code (defaults to all namespaces unless specifically excluded with the nsExclude option) |
nsExclude |
|
|
Namespace to specifically exclude from the generated code (defaults to none excluded until first namespace included with nsInclude option) |
properties |
|
|
Names and values of a properties for use by the custom GeneratorFactory |
outputDir |
|
|
Output directory for emitted files |
wsdlProperties |
|
|
List of additional properties for WSDL2Java command line tool. |
args |
|
|
List of additional arguments for WSDL2Java command line tool. |
wsdlFile |
|
The default output dir is <project build dir>/generated/wsdl2java/axis1/<configuration name>
Property |
Type |
Default value |
Description |
async |
|
|
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. |
sync |
|
|
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. |
serverSide |
|
|
Generates server side code (i.e. skeletons). |
serviceDescription |
|
|
Generates the service descriptor (i.e. server.xml). Default is false. + Only valid if serverSide is true, the server side code generation option. |
databindingMethod |
|
|
Specifies the Databinding framework. Valid values are |
generateAllClasses |
|
|
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. |
unpackClasses |
|
|
Unpack classes. This option specifies whether to unpack the classes and generate separate classes for the databinders. |
serviceName |
|
Specifies the service name to be code generated. If the service name is not specified, then the first service will be picked. |
|
portName |
|
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. |
|
serversideInterface |
|
|
Generate an interface for the service skeleton. |
wsdlVersion |
|
WSDL Version. Valid Options : 2, 2.0, 1.1 |
|
flattenFiles |
|
|
Flattens the generated files if true |
unwrapParams |
|
|
Switch on un-wrapping, if this value is true. |
xsdconfig |
|
|
Use XMLBeans .xsdconfig file if this value is true. This is only valid if databindingMethod is 'xmlbeans'. |
allPorts |
|
|
Generate code for all ports |
backwordCompatible |
|
|
Generate Axis 1.x backword compatible code |
suppressPrefixes |
|
|
Suppress namespace prefixes (Optimzation that reduces size of soap request/response) |
noMessageReceiver |
|
|
Don’t generate a MessageReceiver in the generated sources |
sourceSetName |
|
|
Name of the source set for generated Java code default value is 'main' |
packageName |
|
The target package name. If omitted, a default package (formed using the target namespace of the WSDL) will be used. |
|
namespacePackageMappings |
|
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. |
|
generateTestcase |
|
|
Generates a test case. In the case of Java it would be a JUnit test case. |
namespacePackageMappingFile |
|
Specify an external mapping file |
|
outputDir |
|
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. |
|
args |
|
List of additional arguments for WSDL2Java command line tool. |
|
wsdlFile |
|
Input WSDL file |
The default output dir is <project build dir>/generated/wsdl2java/axis2/<configuration name>
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.
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.
The base configuration uses dependencies of Axis 1 with version 1.4.
'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.
The base configuration uses dependencies of Axis 1 with version 1.7.7
'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'.
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'
}
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.