java2ws — generates a WSDL document from Java code
java2ws
[[-?] | [-help] | [-h]] [-frontend { jaxws | simple }] [-databinding { jaxb | aegis }] [-wsdl] [-wrapperbean] [-client] [-server] [-ant] [-o outFile
] [-s sourceDir
] [-d resourceDir
] [-classdir classDir
] [-cp classpath
] [-soap12] [-t targetNamespace
] [-beans beanPath
...] [-servicename serviceName
] [-portname portName
] [-createxsdimports] [-v] [[-verbose] | [-quiet]] classname
java2ws takes a service endpoint implementation (SEI) and generates the support files used to implement a Web service. java2ws can generate the following:
a WSDL document
the server code needed to deploy the service as a POJO
client code for accessing the service
wrapper and fault beans
The arguments used to manage the code generation process are reviewed in the following table.
Option | Interpretation |
---|---|
-? | Displays the online help for this utility. |
-help | |
-h | |
-frontend {jaxws|simple} | Specifies front end to use for processing the SEI and generating the support classes. jaxws is the default. |
-databinding {jaxb|aegis} | Specifies the data binding used for processing the SEI and generating the support classes. The default when using the JAX-WS front end is jaxb . The default when using the simple frontend is aegis . |
-wsdl | Instructs the tool to generate a WSDL document. |
-wrapperbean | Instructs the tool to generate the wrapper bean and the fault beans. |
-client | Instructs the tool to generate client code. |
-server | Instructs the tool to generate server code. |
-ant | Instructs the tool to generate an Ant build script to compile the generated code. |
-o | Specifies the name of the generated WSDL file. |
-s | Specifies the directory into which the generated source files are placed. |
-d | Specifies the directory into which the resource files are placed. |
-classdir | Specifies the directory into which the generated source files are compiled. If this option is not used, the generated source is not compiled. |
-cp | Specifies the classpath searched when processing the SEI. |
-soap12 | Specifies that the generated WSDL document is to include a SOAP 1.2 binding. |
-t | Specifies the target namespace to use in the generated WSDL file. |
-beans | Specifies the path used to locate the bean definition files. |
-servicename | Specifies the value of the generated service element's name attribute. |
-portname | Specify the value of the generated port element's name attribute. |
-createxsdimports | Instructs the tool to generate separate schemas for the types instead of including the types directly in the generated WSDL document. |
-v | Displays the version number for the tool. |
-verbose | Displays comments during the code generation process. |
-quiet | Suppresses comments during the code generation process. |
classname | Specifies the name of the SEI class. |
To call this tool from Ant you execute the org.apache.cxf.tools.java2ws.JavaToWS
class.
Example 2 shows the java task to generate WSDL from an SEI.
Example 2. Generating WSDL From Ant
<java classname="org.apache.cxf.tools.java2ws.JavaToWS" fork="true"> <arg value="-wsdl"/> <arg value="Service.greeter"/> <classpath> <path refid="fsf.classpath"/> </classpath> </java>