The Java2WSDL ANT task is for launching the Java2WSDL command-line tool in Apache ANT. Java2WSDL translates Java .class files into WSDL documents. More detailed information is given in Java2WSDL.
![]() | Note |
|---|---|
Examples You can find usage examples of ANT tasks in WASP_HOME/src/example/tools/ant and in the build.xml files in Demos. See also Example 214. | |
| Task Name | Task Class |
|---|---|
| Java2WSDL | com.idoox.wasp.tools.ant.Java2WSDLTask |
Example 214. Java2WSDL ANT Task
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="main" name="test">
<taskdef classname="com.idoox.wasp.tools.ant.Java2WSDLTask"
name="java2WSDL"/>
<target name="main">
<java2WSDL addType="test.Structure"
class="test.TestClass,test.test.TestClass" dir="../test_ouptut"
excludeClass="test.TestClass"
namespace2Definition="testNs=testNsDef.wsdl,testTestNs=testTestNsDef.wsdl"
namespace2File="test.TestClass=http://testClass,test.test.TestClass=http://testTestClass"
package2TargetNamespace="test=testNs,test.test=testTestNs"
reuseTypes="true">
<addType name="test.test.Structure"/>
</java2WSDL>
</target>
</project>
| Attribute Name | Description | Required | Command-line Option |
|---|---|---|---|
| alwaysUseSwaRef | If WS-I Attachments are turned on, this forces all attachments to be expressed with a swaRef type and not with an explicit MIME part. Default is false. | No | --always-use-swaRef |
| attachmentType | Type of attachments in WSDL. Use mime for MIME, dime for DIME. Default value is read from WSO2 SOA Enablement Server configuration. | No | --attachment-type |
| addType | Generates a schema type for a given class for output definition(s). Equivalent to the addType sub-element. | No | --add-type |
| attachment | Controls the direction of generated attachments for a given method. The type of attachment is set by a suffix to a method signature: Use + for output, - input and +- for in/out attachments. The attachment may be a comma separated list of method signatures. The attachment sub-element has the same function. | No | --set-attachment |
| class | A comma separated list of classes to be processed. Equivalent to the class sub-element. | Yes | - |
| class2Endpoint | Maps a Java class to a Web service endpoint URI. Equivalent to the class2Endpoint sub-element. | No | --class-mapping |
| class2ServiceName | Maps a Java class to a Web service name. Comma separated class=service_name pairs are expected. Equivalent to the class2ServiceName sub-element. | No | --service-mapping |
| classpathRef | Reference to the classpath element where the task will find the required classes. | No | --classpath |
| deploymentDescriptor | Specifies the filename of the deployment descriptor to be used. When you specify it, you must also set the processing attribute. | No | --deployment-descriptor |
| dir | Specifies the directory where output definition(s) will be stored. The default is the current directory | Yes | --output-directory |
| disableBindings (true/false) | Disables the generation of bindings and services to the output WSDL(s). | No | --disable-bindings |
| excludeClass | Excludes all methods of a given class from the output definition. Java notation can be used. For example: java.lang.* will exclude all classes. Equivalent to the excludeClass sub-element. | No | --exclude-class |
| excludeMethod | Excludes the method of the given class from the output definition. Equivalent to the excludeMethod sub-element. | No | --exclude-method |
| force | Overwrites existing file, when a file with same path as the file being generated exists already. This prevents File already exists-type errors. (=true/false) | No | --force |
| inAttachments | If set to true, attachments are mapped as input parameters. By default, attachments are to be input/output. | No | --set-in-attachments |
| includeClass | Includes a given class in the output definition. Equivalent to the includeClass sub-element. | No | --include-class |
| includeMethod | Includes a method of given class in the output definition. Equivalent to the includeMethod sub-element. | No | --include-method |
| inheritance | Specifies the inheritance path. Comma separated class=superclass pairs are expected. Equivalent to the inheritance sub-element. | No | --inherit |
| insert | A comma separated list of XML Schemas, or a WSDL file, from which previously defined types will be used as the base for compilation. Equivalent to the insert sub-element. | No | --insert |
| javaMappingExtension | If set to false, disables the generation of the extensibility element 'java-operation'. | No | --no-java-mapping-extension |
| namespace2File | Maps the WSDL, identified by its target namespace, to the output filename. Comma separated targetNamespace=definitionSgmltag pairs are expected. Equivalent to the namespace2File sub-element. Backward compatible attribute is namespace2Definition. | No | --output-file-mapping |
| oneWayMethod | Generate the operation as one-way (NO RESPONSE). The value of this attribute is a list of methods. The format of each method is full.qualified.className.method.signature, for example: demo.advanced.oneway.server.OneWayService.mailMe(Ljava/lang/String;)V. Equivalent to the oneWayMethod sub-element. | No | --one-way |
| package2TargetNamespace | Maps a Java package to the WSDL target namespace. Comma separated package=targetNamespace pairs are expected. Equivalent to the package2TargetNamespace sub-element. | No | --package-mapping |
| processing | Sets the name of the processing node (block) in the deployment descriptor. | No | --processing |
| protocol | Choose protocol type. Other protocols will be ignored. Supported protocols are soap11, soap12 and soap11 soap12 for both. Default value is read from WSO2 SOA Enablement Server configuration. | No | --protocol |
| reference | A comma-separated list of the XML Schemas, or a WSDL file, from which previously defined types will be used as the base for compilation. In the resulting WSDL, a reference will be included, as follows: WSDLs are referenced with wsdl:import, XML Schemas are imported in types with xsd:import. Equivalent to the reference sub-element. | No | --reference |
| reuseTypes (true/false) | If set to true, enables the reuse of types, meaning all the types will be in the common WSDL files. | No | --reuse-types |
| singledimArrays | Disables SOAP Sec. 5 array generation. Two dimensional arrays will be generated as a [][] array (an array of arrays), not as a [,] array (Java multidimensional array). | No | --singledim-arrays |
| soapBindingStyle | Specifies the SOAP Binding style. The style can be either rpc, document or wrapped. Default value is read from WSO2 SOA Enablement Server configuration. | No | --soap-binding-style |
| soapEncodingStyle | Specifies the SOAP encoding style. The style can be either literal or encoded. Default value is read from WSO2 SOA Enablement Server configuration. | No | --soap-encoding-style |
| useNillable (true/false) | Sets which attribute should be generated for Java reference data types. If true, nillable="true" is generated. If false, minOccurs=0 is generated. Default value is true. This switch can be useful if you are experiencing trouble communicating with .NET, as C# prefers optional elements to be present rather than nillable. | No | --use-nillable |
| wsiAttachments | Turns on WS-I Attachment Profile 1.0 compliant attachment specification in WSDL. Default value depends on SSJ configuration. | No | --wsi-attachments |
All sub-elements are optional.
Adds an additional fault to the specified method. The method is prefixed with full class name and can contain a signature. The fault is specified with the full name of the Java exception class. Both attributes are mandatory. Equavalent of command line option --add-fault.
| Attribute of addFault | Description |
|---|---|
| method | Specification of method in format fullClassName.method(signature), where the signature and its surrounding parentheses are optional. |
| exception | A fully qualified Java class name of an exception class. |
<java2WSDL...>
<addFault method="com.example.webservice.OperationsIface.echoInt(I)I"
exception="com.example.webservice.exception.SomeException" />
<java2WSDL>
Generates a schema type for a given class for output definition(s).
| Attribute of addType | Description |
|---|---|
| name | Contains the name of the class for which the schema type will be generated. |
This sub-element controls the type of attachments generated for a given method. The type of attachment is set by a suffix to a method signature: Use + for output, - input and +- for in/out attachments. The attachment may be a comma separated list of method signatures.
| Attribute of attachment | Description |
|---|---|
| name | Same format as command-line attribute |
A class to be processed
| Attribute of class | Description |
|---|---|
| name | The name of a class to be processed. |
Maps a Java class to a Web service endpoint URI. It contains two required attributes: class and mapTo. This element is equivalent to the class2Endpoint attribute.
| Attribute of class2endpoint | Description |
|---|---|
| mapTo | Identifies the endpoint URI to which the class is mapped. |
| class | The name of the class that will be mapped. |
Maps a Java class to a Web service name. It contains two required attributes: class and serviceName.
| Attribute of class2ServiceName | Description |
|---|---|
| class | The name of the Java class that will be mapped to the service name. |
| ServiceName | The Web service to which the Java class is mapped. |
Sets the classpath that the task will use to find other classes. It has the same syntax as the classpath sub-element of the java task.
| Attribute of classpath | Description |
|---|---|
| refid | Reference to classpath described elsewhere in the script |
Excludes all methods of a given class from the output definition.
| Attribute of excludeClass | Description |
|---|---|
| name | The class that will be excluded from generation. Java notation can be used. For example: java.lang.* will exclude all classes. |
Excludes the method of the given class from the output definition.
| Attribute of excludeMethod | Description |
|---|---|
| name | The signature of the method that will be excluded from generation. |
Includes a given class in the output definition.
| Attribute of includeClass | Description |
|---|---|
| name | The class that will be included in generation. |
Includes a method of given class in the output definition.
| Attribute of includeMethod | Description |
|---|---|
| name | The signature of the method that will be included in the generated output. |
Specifies the inheritance path.
| Attribute of inheritance | Description |
|---|---|
| name | The name of the class |
| inheritsFrom | The name of the superclass of the class. |
A comma separated list of XML Schemas, or a WSDL file, from which previously defined types will be used as the base for compilation. See also <reference>.
| Attribute of insert | Description |
|---|---|
| name | Contains one required parameter, holding the path to an XML or WSDL file from which the types will be taken. |
Maps the WSDL, identified by its target namespace, to the output definition filename. Equivalent to the namespace2File attribute. Backward compatible element is <namespace2Definition>.
| Attribute of namespace2File | Description |
|---|---|
| namespace | Target namespace of WSDL file |
| filename | Output definition filename |
Generate the operation as one-way (NO RESPONSE).
| Attribute of oneWayMethod | Description |
|---|---|
| name | The signature of the method to be generated as 'one-way' (NO RESPONSE). |
Maps a Java package to the WSDL target namespace.
| Attribute of package2TargetNamespace | Description |
|---|---|
| package | The name of the package that is to be mapped to the specified namespace |
| namespace | The namespace to which the package is mapped |
Uses types defined in an existing XML Schema or WSDL file to compile the Java file to WSDL. Insert wsdl:import reference to target WSDL.
| Attribute of reference | Description |
|---|---|
| name | The path to the XML or WSDL file from which the types will be taken. |