org.idoox.wasp.tools.wsdl2java
Interface WSDL2Java

All Known Subinterfaces:
WSDLCompiler

public interface WSDL2Java

This WSDL2Java is an interface for the WSDL2Java generator tool.

This tool processes WSDL files and generates Java classes along the definitions.

To specify the source WSDL definition you can use either setDefinition(javax.wsdl.Definition) or setEndpoint(org.idoox.transport.client.Endpoint) method.
To read the WSDL definition you can use class WSDLReader which can be obtained using WSDLFactory.newWSDLReader().

 

Using the method #setOutputBackends) it is possible to specify the output backend. There are different output backends for e.g. Java interfaces, Java interfaces for asynchronous calls, Java default implementation etc. The list of output backends can be found in the deployment descriptor (package.xml) of the core_tools package, which is one of the WSO2 SOA Enablement Server packages.

Using the method {@link #setCompilerIO} it is possible to specify where should be the generated classes written. You can either provide your own implementation of the {@link CompilerIO} interface or use simple implementation {@link org.idoox.wasp.tools.common.FileCompilerIO}. Please note this method must be called before you try to call {@link #process} method.

Since:
4.5
Component:
Core-Tools

Nested Class Summary
static class WSDL2Java.JavaVersion
          Represents version of Java.
 
Field Summary
static int MODE_FROM_BINDING
           
static int MODE_FROM_PORTTYPE
           
static int MODE_FROM_SERVICE
           
static int MODE_TYPES_AS_INTERFACES
           
static int MODE_TYPES_AS_JAVABEANS
           
static int MODE_TYPES_AS_STRUCTURES
           
static int PROTOCOL_HTTPGET
          Constant representing HTTP GET binding
static int PROTOCOL_SOAP11
          Constant representing SOAP 1.1 XML protocol.
static int PROTOCOL_SOAP12
          Constant representing SOAP 1.2 XML protocol.
 
Method Summary
 java.lang.String[] getAvailableBackends()
          Returns available WSDL2Java's backends.
 CompilerIO getCompilerIO()
          Returns the compilerIO.
 Processing getDDProcessing()
          returns the Processing
 Definition getDefinition()
          Returns the WSDL definition.
 Endpoint getEndpoint()
          Returns the definition's endpoint
 boolean getGeneratingLiteralAsDOM()
          returns true if mapping literal into DOM element, false otherwise
 java.lang.String getIfacesPackage()
          returns the package into which interfaces are generated
 int getMode()
          returns the processing mode
 java.util.Map getNamespace2PackageMapping()
          Returns a local mapping from XML schema namespace to Java package name.
 int getProtocol()
          Returns preferred protocol.
 java.util.Map getSchema2JavaExceptionMapping()
          Retuns the current schema qname -> java exception class name mapping.
 java.util.Map getSchema2JavaMapping()
          Returns a local mapping from XML Schema types to Java classes.
 WSDL2Java.JavaVersion getTargetJava()
           
 int getTypesGeneratingMode()
          returns generating mode for types
 java.lang.String getTypesPackage()
          returns the package into which types are generated
 int getVerbosityLevel()
          Returns the verbosity level.
 boolean isBeautifyingOutputStructures()
          Returns true if beautification of output structures is activated.
 boolean isGeneratingAllTypes()
          Deprecated. always returns true
 boolean isMapMixedToDom()
           
 boolean isNothingGenerated()
          Returns true if nothing was generated (in this case, when WSDL2Java finishes, warning is output to the user.
 boolean isUnwrap()
          Returns value of the "unwrap" property.
 void process()
          Processes the definition and writes the output using the compilerIO, which must be previously set.
 void setBeautifyingOutputStructures(boolean beautifyingOutputStructures)
          Sets if beautifying output structures is activated.
 void setCompilerIO(CompilerIO compilerIO)
          Sets the compilerIO.
 void setDDProcessing(Processing processing)
          Sets the Processing.
 void setDefinition(Definition wsdl)
          Sets the definition document to be processed.
 void setEndpoint(Endpoint endpoint)
          Sets the definition's endpoint.
 void setGeneratedPort(java.lang.String port)
          Generate only this port from the definition.
 void setGeneratedPortType(QName portType)
          Generate only this port type from the definition.
 void setGeneratedService(QName serviceQName)
          Generate only this service from the definition.
 void setGeneratingAllTypes(boolean generatingAllTypes)
          Deprecated. always set to true
 void setGeneratingLiteralAsDOM(boolean generateLiteralAsDOM)
          Set to true if mapping literal into DOM element, false otherwise
 void setIfacesPackage(java.lang.String packageName)
          Sets the name of the Java package into which the interfaces are generated.
 void setMapMixedToDom(boolean value)
          Sets the property setting handling of mixed content.
 void setMode(int mode)
          sets the processing mode
 void setNamespace2PackageMapping(java.util.Map namespace2PackageMapping)
          Sets a local mapping from XML schema namespace to Java package name.
 void setNothingGenerated(boolean nothingGenerated)
          sets the nothing generated flag.
 void setOutputBackends(java.lang.String outputBackends)
          Sets the output backends mentioned in the configuration, for example java, java-async, java-impl.
 void setProtocol(int protocol)
          Sets preferred protocol.
 void setSchema2JavaExceptionMapping(java.util.Map schema2JavaMapping)
          Sets the schema qname -> java exception class name mapping.
 void setSchema2JavaMapping(java.util.Map schema2JavaMapping)
          Sets a local mapping from XML Schem types to Java classes.
 void setTargetJava(WSDL2Java.JavaVersion version)
          Sets the target java version of generated source.
 void setTypesGeneratingMode(int mode)
          Sets generating mode for types.
 void setTypesPackage(java.lang.String packageName)
          Sets the name of the Java package into which the types from WSDL are generated.
 void setUnwrap(boolean shouldUnwrap)
          Set whether the WSDL2Java should unwrap the wrapping elements around parameters in operations with "wrapped" document/literal style.
 void setVerbosityLevel(int verbosityLevel)
          Sets if verbose output is printed.
 

Field Detail

PROTOCOL_SOAP11

public static final int PROTOCOL_SOAP11
Constant representing SOAP 1.1 XML protocol.

See Also:
Constant Field Values

PROTOCOL_SOAP12

public static final int PROTOCOL_SOAP12
Constant representing SOAP 1.2 XML protocol.

See Also:
Constant Field Values

PROTOCOL_HTTPGET

public static final int PROTOCOL_HTTPGET
Constant representing HTTP GET binding

See Also:
Constant Field Values

MODE_FROM_SERVICE

public static final int MODE_FROM_SERVICE
See Also:
Constant Field Values

MODE_FROM_BINDING

public static final int MODE_FROM_BINDING
See Also:
Constant Field Values

MODE_FROM_PORTTYPE

public static final int MODE_FROM_PORTTYPE
See Also:
Constant Field Values

MODE_TYPES_AS_STRUCTURES

public static final int MODE_TYPES_AS_STRUCTURES
See Also:
Constant Field Values

MODE_TYPES_AS_INTERFACES

public static final int MODE_TYPES_AS_INTERFACES
See Also:
Constant Field Values

MODE_TYPES_AS_JAVABEANS

public static final int MODE_TYPES_AS_JAVABEANS
See Also:
Constant Field Values
Method Detail

setDefinition

public void setDefinition(Definition wsdl)
Sets the definition document to be processed. The Definition can be obtained using the WSDLReader.
You can also specify the source definition using the method setEndpoint(org.idoox.transport.client.Endpoint).

Parameters:
wsdl - the definition document to be processed after call the process() method

getDefinition

public Definition getDefinition()
Returns the WSDL definition.

Returns:
the previously set WSDL definition or null if not set

setEndpoint

public void setEndpoint(Endpoint endpoint)
Sets the definition's endpoint. If there is no definition set (setDefinition(javax.wsdl.Definition)) when calling process() method, it will be loaded from the specified endpoint.
The endpoint can be constructed e.g. from a String representation of an URL.

Parameters:
endpoint - the definition's endpoint

getEndpoint

public Endpoint getEndpoint()
Returns the definition's endpoint

Returns:
the previously set definition's endpoint or null if not set

setCompilerIO

public void setCompilerIO(CompilerIO compilerIO)
Sets the compilerIO. The compilerIO writes out the output of the compilation process. You can either implement the CompilerIO or use e.g. the FileCompilerIO. This method must be called before the process() method is called.

Parameters:
compilerIO - implementation of CompilerIO interface

getCompilerIO

public CompilerIO getCompilerIO()
Returns the compilerIO.

Returns:
the previously set compilerIO or null if not set

setOutputBackends

public void setOutputBackends(java.lang.String outputBackends)
Sets the output backends mentioned in the configuration, for example java, java-async, java-impl.

Parameters:
outputBackends - name of backends set

getAvailableBackends

public java.lang.String[] getAvailableBackends()
Returns available WSDL2Java's backends.

Returns:
available WSDL2Java's backends

setVerbosityLevel

public void setVerbosityLevel(int verbosityLevel)
Sets if verbose output is printed.

Parameters:
verbosityLevel - the verbosity level (0-10), 0 .. no output

getVerbosityLevel

public int getVerbosityLevel()
Returns the verbosity level.

Returns:
the verbosity level

setMode

public void setMode(int mode)
sets the processing mode

Parameters:
mode - the processing mode

getMode

public int getMode()
returns the processing mode

Returns:
the mode

setDDProcessing

public void setDDProcessing(Processing processing)
Sets the Processing. The processing can be used to customize the compilation process.

Parameters:
processing - the processing

getDDProcessing

public Processing getDDProcessing()
returns the Processing

Returns:
the processing

setGeneratingAllTypes

public void setGeneratingAllTypes(boolean generatingAllTypes)
Deprecated. always set to true


isGeneratingAllTypes

public boolean isGeneratingAllTypes()
Deprecated. always returns true


setIfacesPackage

public void setIfacesPackage(java.lang.String packageName)
Sets the name of the Java package into which the interfaces are generated.

Parameters:
packageName - package into which interfaces are generated, must be a valid Java package name

getIfacesPackage

public java.lang.String getIfacesPackage()
returns the package into which interfaces are generated

Returns:
the package into which interfaces are generated

setTypesPackage

public void setTypesPackage(java.lang.String packageName)
Sets the name of the Java package into which the types from WSDL are generated. This behavior can be overriden using setSchema2JavaMapping(java.util.Map).

Parameters:
packageName - package into which types are generated, must ba valid Java package name

getTypesPackage

public java.lang.String getTypesPackage()
returns the package into which types are generated

Returns:
the package into which types are generated

setTypesGeneratingMode

public void setTypesGeneratingMode(int mode)
Sets generating mode for types. One of: MODE_TYPES_AS_STRUCTURES (default one), MODE_TYPES_AS_JAVABEANS, MODE_TYPES_AS_INTERFACES

Parameters:
mode - generating mode for types

getTypesGeneratingMode

public int getTypesGeneratingMode()
returns generating mode for types

Returns:
generating mode for types, one of: MODE_TYPES_AS_STRUCTURES (default one), MODE_TYPES_AS_JAVABEANS, MODE_TYPES_AS_INTERFACES

setGeneratingLiteralAsDOM

public void setGeneratingLiteralAsDOM(boolean generateLiteralAsDOM)
Set to true if mapping literal into DOM element, false otherwise

Parameters:
generateLiteralAsDOM - true if mapping literal into DOM element, false otherwise

getGeneratingLiteralAsDOM

public boolean getGeneratingLiteralAsDOM()
returns true if mapping literal into DOM element, false otherwise

Returns:
true if mapping literal into DOM element, false otherwise

setGeneratedService

public void setGeneratedService(QName serviceQName)
Generate only this service from the definition.

Parameters:
serviceQName - service to be generated

setGeneratedPort

public void setGeneratedPort(java.lang.String port)
Generate only this port from the definition.

Parameters:
port - port to be generated

setGeneratedPortType

public void setGeneratedPortType(QName portType)
Generate only this port type from the definition.

Parameters:
portType - port type to be generated

isBeautifyingOutputStructures

public boolean isBeautifyingOutputStructures()
Returns true if beautification of output structures is activated.

Returns:
true if beautification of output structures is activated.

setBeautifyingOutputStructures

public void setBeautifyingOutputStructures(boolean beautifyingOutputStructures)
Sets if beautifying output structures is activated. (by default it is activated).
For better interoperability with Microsoft .NET, WSO2 SOA Enablement Server Schema2Java optimizes the XML Schema file. The structures so generated do not strictly conform to XML Schema.
This behavior can be switched off using this option.

Parameters:
beautifyingOutputStructures - if true a beautification mode is activated, if false otherwise.

getSchema2JavaMapping

public java.util.Map getSchema2JavaMapping()
Returns a local mapping from XML Schema types to Java classes.

Returns:
a local mapping

setSchema2JavaMapping

public void setSchema2JavaMapping(java.util.Map schema2JavaMapping)
Sets a local mapping from XML Schem types to Java classes. It overrides the behavior of setSchema2JavaMapping(java.util.Map) and setTypesPackage(java.lang.String). .

Parameters:
schema2JavaMapping - mapping between the schema types and the Java classes. The key of this map is allways QName of the XSD type, the value is the String name of the Java class

getSchema2JavaExceptionMapping

public java.util.Map getSchema2JavaExceptionMapping()
Retuns the current schema qname -> java exception class name mapping.

Returns:
the mapping; can be null

setSchema2JavaExceptionMapping

public void setSchema2JavaExceptionMapping(java.util.Map schema2JavaMapping)
Sets the schema qname -> java exception class name mapping.

Parameters:
schema2JavaMapping - the new mapping

setNamespace2PackageMapping

public void setNamespace2PackageMapping(java.util.Map namespace2PackageMapping)
Sets a local mapping from XML schema namespace to Java package name. It overrides the behavior of setTypesPackage(java.lang.String). Type of the key is String, type of the value is String

Parameters:
namespace2PackageMapping -

getNamespace2PackageMapping

public java.util.Map getNamespace2PackageMapping()
Returns a local mapping from XML schema namespace to Java package name. This mapping overrides the behavior of setTypesPackage(java.lang.String).

Returns:
mapping from XML schema namespace to Java package name, type of the key is String, type of the value is String

process

public void process()
             throws WSDL2JavaException
Processes the definition and writes the output using the compilerIO, which must be previously set. Before calling process method set use the setCompilerIO(org.idoox.wasp.tools.CompilerIO) to specify where the output should be written and also set the definition to be processed - you can do this with either setDefinition(javax.wsdl.Definition) or setEndpoint(org.idoox.transport.client.Endpoint) method.
The setDefinition(javax.wsdl.Definition) method uses the Definition form of the WSDL - see the WSDLReader how to obtain it.
If you use the setEndpoint(org.idoox.transport.client.Endpoint) method, you have to consruct the Endpoint e.g. from a String representation of the WSDL URL.

Throws:
WSDL2JavaException

isNothingGenerated

public boolean isNothingGenerated()
Returns true if nothing was generated (in this case, when WSDL2Java finishes, warning is output to the user.

Returns:
true if nothing was generated

setNothingGenerated

public void setNothingGenerated(boolean nothingGenerated)
sets the nothing generated flag. This method is usually called from a backend to get known that something has been already generated.

Parameters:
nothingGenerated - true if nothing has been generated at all.

setProtocol

public void setProtocol(int protocol)
Sets preferred protocol. Uses PROTOCOL_SOAP11 and PROTOCOL_SOAP12 constants.
This applies if there are two bindings of one port, each for one protocol.

Parameters:
protocol - preferred protocol, one of PROTOCOL_SOAP11, PROTOCOL_SOAP12

getProtocol

public int getProtocol()
Returns preferred protocol. Uses PROTOCOL_SOAP11 constants.

Returns:
preferred protocol

setUnwrap

public void setUnwrap(boolean shouldUnwrap)
Set whether the WSDL2Java should unwrap the wrapping elements around parameters in operations with "wrapped" document/literal style. The default values is taken from WSO2 SOA Enablement Server configuration (if the default binding style is "wrapped", the value is true. The WSDL2Java recognize these operations when all of the next conditions are fullfilled: It means, all method parameters are wrapped up in the top level schema element. The element's name is same like the name of the operation for input message, operation name + "Response" for the output message. This type of WSDLs is required by the WS-I basic profile. When setting the "unwrap" property false, WSDL2Java will generate Java structures corresponding to these wrapper elements with the fields inside.

Parameters:
shouldUnwrap - unwrap or

isUnwrap

public boolean isUnwrap()
Returns value of the "unwrap" property.

See Also:
setUnwrap(boolean)

setMapMixedToDom

public void setMapMixedToDom(boolean value)
Sets the property setting handling of mixed content. true means that mixed complex type is mapped to an DOM element, false means that the character data are ignored and only subelements are considered.

Parameters:
value - a new value of the property
Since:
SSJ 6.5.2

isMapMixedToDom

public boolean isMapMixedToDom()
Returns:
the currently set of value of the property
Since:
SSJ 6.5.2
See Also:
setMapMixedToDom(boolean)

setTargetJava

public void setTargetJava(WSDL2Java.JavaVersion version)
Sets the target java version of generated source.

Parameters:
version - a new version; not null'
Since:
SSJ 6.5.2

getTargetJava

public WSDL2Java.JavaVersion getTargetJava()
Returns:
return the currently set target java version
Since:
SSJ 6.5.2
See Also:
setTargetJava(org.idoox.wasp.tools.wsdl2java.WSDL2Java.JavaVersion)