|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Java2WSDL interface is an interface of for the WSDL generator tool.
See Java2WSDLFactory
how to
get an instance of the Java2WSDL and how to use it via API.
Here is the example how to use the Java2WSDL. The first example shows how
to get the WSDL for the HelloService
class as the instance
of Definition
class from the WSDL API.
Java2WSDL java2wsdl = Java2WSDLFactory.newJava2WSDL(); Definition definition = java2wsdl.generateDefinition(HelloService.class);If you want to set the generated definition to the created endpoint you can use method
ServiceEndpoint.setWSDL(javax.wsdl.Definition)
.
HelloService
as a file. You have to set the
output using the method setCompilerIO(org.idoox.wasp.tools.CompilerIO)
. You can either
implement the interface CompilerIO
by
yourself or e.g. use the
FileCompilerIO
which contains
the output destination directory to be specified in its constructor.
The generated WSDL document(s) will be placed there.
Java2WSDL java2wsdl = Java2WSDLFactory.newJava2WSDL(); java2wsdl.setCompilerIO(new FileCompilerIO("/output")); java2wsdl.process(HelloService.class);
Java2WSDL factory
,
WSDL definition
,
set the WSDL definition to service endpoint
Nested Class Summary | |
static class |
Java2WSDL.ServiceDefinition
Service definition. |
Field Summary | |
static java.lang.String |
ATTACHMENT_TYPE_DIME
generate attachments as DIME |
static java.lang.String |
ATTACHMENT_TYPE_MIME
generate attachments as MIME |
static int |
BINDING_STYLE_DOCUMENT
Binding style DOCUMENT. |
static int |
BINDING_STYLE_RPC
Binding style RPC. |
static int |
BINDING_STYLE_WRAPPED
Binding style WRAPPED. |
static int |
MODE_ATTACHMENTS_AS_IN
Map attachments as in. |
static int |
MODE_ATTACHMENTS_AS_INOUT
Map attachments as in/out. |
static int |
MODE_INTERFACE_TO_REMOTE_REF
Map interfaces to remote references. |
static int |
MODE_INTERFACE_TO_STRUCTURE
Map interfaces to structures. |
static int |
MODE_TO_BINDING
Generate partial WSDL including Binding but exluding Service. |
static int |
MODE_TO_PORTTYPE
Generate partial WSDL excluding Binding and Service. |
static int |
MODE_TO_SERVICE
Generate complete WSDL including Binding and Service. |
static int |
PROTOCOL_HTTPGET
HTTP GET binding |
static int |
PROTOCOL_SOAP11
SOAP 1.1 protocol binding |
static int |
PROTOCOL_SOAP11_SOAP12
SOAP1.1 and SOAP 1.2 protocol. |
static int |
PROTOCOL_SOAP12
SOAP 1.2 protocol binding |
static int |
SOAP_USE_ENCODED
Use SOAP-ENC encoding (SOAP spec. |
static int |
SOAP_USE_LITERAL
Use literal encoding. |
Method Summary | |
void |
addHeaders(Header[] header,
Schema[] schemata)
Adds headers which will be generated to WSDL. |
Definition |
generateDefinition(java.lang.Class clazz)
Generates definition from the specified class. |
Definition[] |
generateDefinitions(java.lang.Class clazz)
Deprecated. use generateDefinition(java.lang.Class) instead. |
Definition[] |
generateDefinitions(java.lang.Class[] classes)
Generates definitions and returns an array of them. |
int |
getAttachmentsMappingMode()
Returns attachments mapping mode. |
java.lang.String |
getAttachmentType()
Get type of attachments to be generated - MIME or DIME. |
int |
getBindingStyle()
Returns binding style. |
java.lang.ClassLoader |
getClassloader()
Returns ClassLoader for both, classes and sources. |
java.lang.String |
getClasspath()
Returns classpath for both, classes and sources. |
CompilerIO |
getCompilerIO()
Returns the compilerIO. |
Processing |
getDDProcessing()
Returns the DeploymentDescriptor processing |
java.util.Set |
getExcludedClasses()
Returns a set of excluded classes. |
java.util.Set |
getExcludedMethods()
Returns a set of methods to exclude from processing. |
java.util.Set |
getExtraTypes()
Returns extra types to generate. |
java.util.Set |
getIncludedClasses()
Returns a set of included classes. |
java.util.Set |
getIncludedMethods()
Returns a set of methods to include to processing. |
java.util.Map |
getInheritanceMapping()
Returns inheritance map of class -> superclass. |
int |
getInterfaceMappingMode()
Returns mode of interface mapping. |
int |
getMode()
Returns the processing mode (what parts of WSDL should be generated). |
java.util.Set |
getMultipartMethods()
Returns a set of multipart methods. |
java.util.Map |
getNamespaceMapping()
Returns map of targetNamespace -> filename. |
java.util.Set |
getOneWayMethods()
Returns a set of methods which should be generated in one-way style. |
java.util.Map |
getPackageMapping()
Returns map of package-name -> targetNamespace. |
int |
getProtocol()
Returns protocol for generated WSDL. |
java.lang.String |
getSerializationID()
Returns serialization ID to use. |
java.util.Map |
getServiceMapping()
Returns map of service class name -> Service. |
int |
getSOAPEncoding()
Returns type of SOAP encoding. |
boolean |
isAlwaysUseWsiSwaref()
Get the current value of the property. |
boolean |
isIntrospectingSources()
Returns if source introspection is enabled. |
boolean |
isJavaMappingExtension()
Returns if java mapping extensibility elements are enabled. |
boolean |
isMultidimArrays()
Returns type of generated arrays. |
boolean |
isOneWayMethod(java.lang.reflect.Method method)
Sets this method is one-way method. |
boolean |
isReusingTypes()
Returns if reusing types. |
boolean |
isRuntimeMode()
Returns if runtime mode enabled. |
boolean |
isSortingFields()
Returns if alphabetically sorting fields. |
boolean |
isUseWsiMimeAttachments()
Gets the current setting of the property. |
boolean |
isVerbose()
Returns if in verbose mode. |
void |
process(java.lang.Class clazz)
Processes given class and generates WSDL files. |
void |
process(java.lang.Class[] classes)
Processes given classes and generates WSDL files. |
void |
setAdditionalExceptions(java.util.Map map)
Sets additional SOAP faults to create in the WSDL. |
void |
setAlwaysUseWsiSwaref(boolean newValue)
Sets a new property value. |
void |
setAttachmentsMappingMode(int mode)
Sets attachments mapping mode, default is MODE_ATTACHMENTS_AS_INOUT ,
the others are
MODE_ATTACHMENTS_AS_IN . |
void |
setAttachmentType(java.lang.String type)
Set type of attachments to be generated - MIME or DIME. |
void |
setBindingStyle(int bindingStyle)
Sets the binding style. |
void |
setClassloader(java.lang.ClassLoader classLoader)
Sets ClassLoader for both, classes and sources. |
void |
setClasspath(java.lang.String classpath)
Sets classpath for both, classes and sources. |
void |
setCompilerIO(CompilerIO compilerIO)
Sets the compilerIO. |
void |
setDDProcessing(Processing processing)
Sets the DeploymentDescriptor processing |
void |
setExtraTypes(java.util.Set extraTypes)
Sets extra types to generate. |
void |
setInheritanceMapping(java.util.Map inheritanceMapping)
Sets inheritance map of class -> superclass. |
void |
setInterfaceMappingMode(int mode)
Sets mode of interface mapping, default is MODE_INTERFACE_TO_STRUCTURE ,
the other one is
MODE_INTERFACE_TO_REMOTE_REF |
void |
setIntrospectingSources(boolean introspectSources)
Enables/disables source introspection. |
void |
setJavaMappingExtension(boolean javaMappingExtension)
Enables/disables java mapping extensibility elements. |
void |
setMappingSchemas(java.util.Set referencedSchemas,
java.util.Set insertedSchemas)
Sets XML Schemas / WSDLs to take its types as the base for compilation. |
void |
setMode(int mode)
Sets the processing mode (what parts of WSDL should be generated). |
void |
setMultidimArrays(boolean multidimArrays)
Enables/disables generating of multidimensional arrays. |
void |
setMultipartMethods(java.util.Set multipartMethods)
Sets multipart methods. |
void |
setNamespaceMapping(java.util.Map namespaceFileNameMapping)
Sets map of targetNamespace -> filename. |
void |
setOneWayMethod(java.lang.reflect.Method method,
boolean isOneWay)
Sets if the specified method is one-way method. |
void |
setOneWayMethods(java.util.Set oneWayMethods)
Sets a set of methods which should be generated in one-way style. |
void |
setPackageMapping(java.util.Map packageNamespaceMapping)
Sets map of package-name -> targetNamespace. |
void |
setProtocol(int protocol)
Sets protocol protocol binding for generated WSDL. |
void |
setReusingTypes(boolean reuseTypes)
Enables/disables types reusing. |
void |
setRuntimeMode(java.lang.String endpointURI)
UNDOCUMENTED. |
void |
setSerializationID(java.lang.String serializationID)
Sets serialization ID to use. |
void |
setServiceMapping(java.util.Map serviceMapping)
Sets map of service class name -> Service. |
void |
setSOAPEncoding(int soapEncoding)
Sets type of SOAP encoding. |
void |
setSortingFields(boolean sortingFields)
Enables/disables alphabetically sorting of fields. |
void |
setUseNillable(boolean b)
Sets whether attribute nillable='true' or attributes minOccurs='0' maxOccurs='1'
should be generated into XML schema for Java reference data types. |
void |
setUseWsiMimeAttachments(boolean newValue)
Sets a new property value. |
void |
setVerbose(boolean verbose)
Sets verbose output is to be printed. |
void |
setVerbose(int length)
Enables verbose mode and sets output message max length. |
boolean |
testClassInclusion(java.lang.String className)
Tests class processing inclusion. |
boolean |
testMethodInclusion(java.lang.String methodSignature)
Tests method processing inclusion. |
Field Detail |
public static final int MODE_TO_SERVICE
public static final int MODE_TO_BINDING
public static final int MODE_TO_PORTTYPE
public static final int BINDING_STYLE_RPC
setBindingStyle(int)
,
Constant Field Valuespublic static final int BINDING_STYLE_DOCUMENT
setBindingStyle(int)
,
Constant Field Valuespublic static final int BINDING_STYLE_WRAPPED
BINDING_STYLE_DOCUMENT
style
with the "wrapped" approach to the operation parameters.
All parameters of the operation are "wrapped" into the one wrapping
element, so the message has only one part. SOAP_USE_LITERAL
(using method setSOAPEncoding(int)
).
setBindingStyle(int)
,
Constant Field Valuespublic static final int SOAP_USE_ENCODED
setSOAPEncoding(int)
,
Constant Field Valuespublic static final int SOAP_USE_LITERAL
setSOAPEncoding(int)
,
Constant Field Valuespublic static final int MODE_INTERFACE_TO_STRUCTURE
public static final int MODE_INTERFACE_TO_REMOTE_REF
public static final int MODE_ATTACHMENTS_AS_INOUT
public static final int MODE_ATTACHMENTS_AS_IN
public static final int PROTOCOL_SOAP11
setProtocol(int)
,
Constant Field Valuespublic static final int PROTOCOL_SOAP12
setProtocol(int)
,
Constant Field Valuespublic static final int PROTOCOL_HTTPGET
setProtocol(int)
,
Constant Field Valuespublic static final int PROTOCOL_SOAP11_SOAP12
setProtocol(int)
,
Constant Field Valuespublic static final java.lang.String ATTACHMENT_TYPE_DIME
public static final java.lang.String ATTACHMENT_TYPE_MIME
Method Detail |
public void process(java.lang.Class clazz)
Note: Before using this method you should set all the properties, mainly CompilerIO.
clazz
- class to processpublic void process(java.lang.Class[] classes)
Note: Before using this method you should set all the properties, mainly CompilerIO.
classes
- classes to processpublic Definition generateDefinition(java.lang.Class clazz)
setCompilerIO(org.idoox.wasp.tools.CompilerIO)
.
clazz
- class to process
public Definition[] generateDefinitions(java.lang.Class clazz)
generateDefinition(java.lang.Class)
instead.
clazz
- class to process
public Definition[] generateDefinitions(java.lang.Class[] classes)
classes
- classes to process
public void setCompilerIO(CompilerIO compilerIO)
CompilerIO
or use e.g.
the FileCompilerIO
.
Note: CompilerIO must be set explicitely to use
process(java.lang.Class)
methods.
compilerIO
- compiler I/O helperpublic CompilerIO getCompilerIO()
public int getInterfaceMappingMode()
public void setInterfaceMappingMode(int mode)
MODE_INTERFACE_TO_STRUCTURE
,
the other one is
MODE_INTERFACE_TO_REMOTE_REF
mode
- mode of interface mappingpublic int getAttachmentsMappingMode()
public void setAttachmentsMappingMode(int mode)
MODE_ATTACHMENTS_AS_INOUT
,
the others are
MODE_ATTACHMENTS_AS_IN
.
mode
- mode of attachments mappingpublic java.util.Map getPackageMapping()
public void setPackageMapping(java.util.Map packageNamespaceMapping)
packageNamespaceMapping
- map of package-name -> targetNamespacepublic java.util.Map getNamespaceMapping()
public void setNamespaceMapping(java.util.Map namespaceFileNameMapping)
namespaceFileNameMapping
- map of targetNamespace -> filenamepublic java.util.Map getServiceMapping()
public void setServiceMapping(java.util.Map serviceMapping)
Each key in the map must be a String (Service class name), each value in
the map must be a Java2WSDL.ServiceDefinition
.
serviceMapping
- map of service class name -> Servicepublic void setMode(int mode)
mode
- the processing mode (default is
MODE_TO_SERVICE
, others are MODE_TO_BINDING
,
MODE_TO_PORTTYPE
).public int getMode()
public java.util.Set getExcludedClasses()
public java.util.Set getIncludedClasses()
public java.util.Set getExcludedMethods()
public java.util.Set getIncludedMethods()
public void setMappingSchemas(java.util.Set referencedSchemas, java.util.Set insertedSchemas)
referencedSchemas
- relative or absolute URLs of schema files (stored as String);
these schemas will be referenced by insertedSchemas
- relative or absolute URLs of schema files (stored as String);
these schemas will be directly includedpublic boolean testClassInclusion(java.lang.String className)
className
- name of class to test
public boolean testMethodInclusion(java.lang.String methodSignature)
methodSignature
- signature of method to test
public java.util.Set getOneWayMethods()
public void setOneWayMethods(java.util.Set oneWayMethods)
oneWayMethods
- a set of methods which should be generated in one-way stylepublic void setOneWayMethod(java.lang.reflect.Method method, boolean isOneWay)
method
- selected methodisOneWay
- true if should be one-way, false if notpublic boolean isOneWayMethod(java.lang.reflect.Method method)
method
- selected method
public java.util.Set getExtraTypes()
public void setExtraTypes(java.util.Set extraTypes)
extraTypes
- a set of extra types to generatepublic boolean isJavaMappingExtension()
public void setJavaMappingExtension(boolean javaMappingExtension)
javaMappingExtension
- public void setVerbose(boolean verbose)
verbose
- true if verbose comments are to be printedpublic void setVerbose(int length)
length
- max length of output message, 0 means default lengthpublic boolean isVerbose()
public boolean isSortingFields()
public void setSortingFields(boolean sortingFields)
sortingFields
- if set to true fields will be sortedpublic java.util.Map getInheritanceMapping()
String
name of the class,
the value is the String
name of the superclass.
public void setInheritanceMapping(java.util.Map inheritanceMapping)
String
name of the class,
the value is the String
name of the superclass.
inheritanceMapping
- of class -> superclasspublic java.lang.String getClasspath()
public void setClasspath(java.lang.String classpath)
classpath
- classpath to setpublic java.lang.ClassLoader getClassloader()
public void setClassloader(java.lang.ClassLoader classLoader)
classLoader
- classLoader to setpublic java.util.Set getMultipartMethods()
public void setMultipartMethods(java.util.Set multipartMethods)
multipartMethods
- a set of multipart methodspublic boolean isReusingTypes()
public void setReusingTypes(boolean reuseTypes)
reuseTypes
- if set to true types reusing will be enabledpublic boolean isRuntimeMode()
public void setRuntimeMode(java.lang.String endpointURI)
public java.lang.String getSerializationID()
public void setSerializationID(java.lang.String serializationID)
serializationID
- serialization ID to usepublic boolean isIntrospectingSources()
public void setIntrospectingSources(boolean introspectSources)
introspectSources
- if set to true sources will be introspectedpublic int getBindingStyle()
BINDING_STYLE_DOCUMENT
,
BINDING_STYLE_WRAPPED
or BINDING_STYLE_RPC
.public void setBindingStyle(int bindingStyle)
BINDING_STYLE_DOCUMENT
,
BINDING_STYLE_WRAPPED
or BINDING_STYLE_RPC
.
If not set, the default value is used. The default values can be found
in the WSO2 SOA Enablement Server configuration file (typically WASP_HOME/conf/serverconf.xml or
WASP_HOME/conf/clientconf.xml), section "preferences".
bindingStyle
- type of binding style - one of
BINDING_STYLE_DOCUMENT
,
BINDING_STYLE_WRAPPED
or BINDING_STYLE_RPC
.public int getSOAPEncoding()
SOAP_USE_LITERAL
or
SOAP_USE_ENCODED
.public void setSOAPEncoding(int soapEncoding)
SOAP_USE_LITERAL
or
SOAP_USE_ENCODED
.
If not set, the default value is used. The default values can be found
in the WSO2 SOA Enablement Server configuration file (typically WASP_HOME/conf/serverconf.xml or
WASP_HOME/conf/clientconf.xml), section "preferences".
soapEncoding
- type of SOAP encodingpublic boolean isMultidimArrays()
public void setMultidimArrays(boolean multidimArrays)
multidimArrays
- set to true if multidim arrays are allowedpublic int getProtocol()
PROTOCOL_SOAP11
,
PROTOCOL_SOAP12
,
PROTOCOL_HTTPGET
or their combination (logical OR)public void setProtocol(int protocol)
PROTOCOL_SOAP11
,
PROTOCOL_SOAP12
,
PROTOCOL_HTTPGET
or you can use logical OR operator to specify more than one protocol
(e.g. Java2WSDL.PROTOCOL_SOAP11 | Java2WSDL.PROTOCOL_HTTPGET).
If not set, the default value is used. The default values can be found
in the WSO2 SOA Enablement Server configuration file (typically WASP_HOME/conf/serverconf.xml or
WASP_HOME/conf/clientconf.xml), section "preferences".
protocol
- constant representing protocol or combination of protocolspublic void addHeaders(Header[] header, Schema[] schemata)
header
- schemata
- public void setAttachmentType(java.lang.String type)
type
- constants ATTACHMENT_TYPE_DIME
, ATTACHMENT_TYPE_MIME
public java.lang.String getAttachmentType()
ATTACHMENT_TYPE_DIME
, ATTACHMENT_TYPE_MIME
public void setDDProcessing(Processing processing)
processing
- DeploymentDescriptor processingpublic Processing getDDProcessing()
public void setUseNillable(boolean b)
nillable='true'
or attributes minOccurs='0' maxOccurs='1'
should be generated into XML schema for Java reference data types.
If not set, default value will be used - see Java2Schema.isUseNillable()
.
b
- use true
to generate with attribute nillable='true'
,
use false
to generate with attributes minOccurs='0' maxOccurs='1'
,Java2Schema.setUseNillable(boolean)
public void setAdditionalExceptions(java.util.Map map)
map
- a null
or map with String
keys and
values Set
of String
; key is representation
of method in format "qualifiedClass.methodName(signature)", where the signature
including parenthesis is optional; strings in value are fully qualified names
of java exceptions
java.lang.IllegalArgumentException
- if any class could not be found or does not contain
the specified method or the method is provided without signature
and is ambiguouspublic boolean isUseWsiMimeAttachments()
If set, the created WSDL will be WS-I Attachment Profile 1.0 compliant (if the classes use any attachments).
Otherwise SSJ 5.5 compliant WSDL is created.
Default is derived from wsiCompliant
value in clientconf.xml
.
public void setUseWsiMimeAttachments(boolean newValue)
newValue
- a new value of the propertyisUseWsiMimeAttachments()
public boolean isAlwaysUseWsiSwaref()
Only effective if isUseWsiMimeAttachments()
is true
. In such case
all attachments are represented as content of body with XML Schema type swaRef
.
Default value is false
meaning that Java2WSDL will use explicit MIME part
not referenced from body if possible.
public void setAlwaysUseWsiSwaref(boolean newValue)
newValue
- a new value of the propertyisAlwaysUseWsiSwaref()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |