ANT Java2WSDL Task  Locate

Overview  Locate

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]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 NameTask Class
Java2WSDLcom.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>

Attributes of the Java2WSDL Task  Locate

Attribute NameDescriptionRequiredCommand-line Option
alwaysUseSwaRefIf 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
attachmentTypeType of attachments in WSDL. Use mime for MIME, dime for DIME. Default value is read from WSO2 SOA Enablement Server configuration.No--attachment-type
addTypeGenerates a schema type for a given class for output definition(s). Equivalent to the addType sub-element.No--add-type
attachmentControls 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
classA comma separated list of classes to be processed. Equivalent to the class sub-element.Yes-
class2EndpointMaps a Java class to a Web service endpoint URI. Equivalent to the class2Endpoint sub-element.No--class-mapping
class2ServiceNameMaps 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
classpathRefReference to the classpath element where the task will find the required classes.No--classpath
deploymentDescriptorSpecifies the filename of the deployment descriptor to be used. When you specify it, you must also set the processing attribute.No--deployment-descriptor
dirSpecifies the directory where output definition(s) will be stored. The default is the current directoryYes--output-directory
disableBindings (true/false)Disables the generation of bindings and services to the output WSDL(s).No--disable-bindings
excludeClassExcludes 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
excludeMethodExcludes the method of the given class from the output definition. Equivalent to the excludeMethod sub-element.No--exclude-method
forceOverwrites 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
inAttachmentsIf set to true, attachments are mapped as input parameters. By default, attachments are to be input/output.No--set-in-attachments
includeClassIncludes a given class in the output definition. Equivalent to the includeClass sub-element.No--include-class
includeMethodIncludes a method of given class in the output definition. Equivalent to the includeMethod sub-element.No--include-method
inheritanceSpecifies the inheritance path. Comma separated class=superclass pairs are expected. Equivalent to the inheritance sub-element.No--inherit
insertA 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
javaMappingExtensionIf set to false, disables the generation of the extensibility element 'java-operation'.No--no-java-mapping-extension
namespace2FileMaps 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
oneWayMethodGenerate 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
package2TargetNamespaceMaps a Java package to the WSDL target namespace. Comma separated package=targetNamespace pairs are expected. Equivalent to the package2TargetNamespace sub-element.No--package-mapping
processingSets the name of the processing node (block) in the deployment descriptor.No--processing
protocolChoose 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
referenceA 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
singledimArraysDisables 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
soapBindingStyleSpecifies 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
soapEncodingStyleSpecifies 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
wsiAttachmentsTurns on WS-I Attachment Profile 1.0 compliant attachment specification in WSDL. Default value depends on SSJ configuration.No--wsi-attachments

Sub-elements of the Java2WSDL ANT Task  Locate

All sub-elements are optional.

<addFault>   Locate

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 addFaultDescription
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>

<addType>   Locate

Generates a schema type for a given class for output definition(s).

Attribute of addTypeDescription
nameContains the name of the class for which the schema type will be generated.
<attachment>   Locate

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 attachmentDescription
nameSame format as command-line attribute
<class>   Locate

A class to be processed

Attribute of classDescription
nameThe name of a class to be processed.
<class2endpoint>   Locate

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 class2endpointDescription
mapToIdentifies the endpoint URI to which the class is mapped.
classThe name of the class that will be mapped.
<class2ServiceName>   Locate

Maps a Java class to a Web service name. It contains two required attributes: class and serviceName.

Attribute of class2ServiceNameDescription
classThe name of the Java class that will be mapped to the service name.
ServiceNameThe Web service to which the Java class is mapped.
<classpath>   Locate

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 classpathDescription
refidReference to classpath described elsewhere in the script
<excludeClass>   Locate

Excludes all methods of a given class from the output definition.

Attribute of excludeClassDescription
nameThe class that will be excluded from generation. Java notation can be used. For example: java.lang.* will exclude all classes.
<excludeMethod>   Locate

Excludes the method of the given class from the output definition.

Attribute of excludeMethodDescription
nameThe signature of the method that will be excluded from generation.
<includeClass>   Locate

Includes a given class in the output definition.

Attribute of includeClassDescription
nameThe class that will be included in generation.
<includeMethod>   Locate

Includes a method of given class in the output definition.

Attribute of includeMethodDescription
nameThe signature of the method that will be included in the generated output.
<inheritance>   Locate

Specifies the inheritance path.

Attribute of inheritanceDescription
nameThe name of the class
inheritsFromThe name of the superclass of the class.
<insert>   Locate

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 insertDescription
nameContains one required parameter, holding the path to an XML or WSDL file from which the types will be taken.
<namespace2File>   Locate

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 namespace2FileDescription
namespaceTarget namespace of WSDL file
filenameOutput definition filename
<oneWayMethod>   Locate

Generate the operation as one-way (NO RESPONSE).

Attribute of oneWayMethodDescription
nameThe signature of the method to be generated as 'one-way' (NO RESPONSE).
<package2TargetNamespace>   Locate

Maps a Java package to the WSDL target namespace.

Attribute of package2TargetNamespaceDescription
packageThe name of the package that is to be mapped to the specified namespace
namespaceThe namespace to which the package is mapped
<reference>   Locate

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 referenceDescription
nameThe path to the XML or WSDL file from which the types will be taken.