29.4. WsGen

WsGen is a new JOnAS tool that works in the same way as GenIC. It takes an archive file (EJB-JAR, WAR, JAR client, or EAR) and generates all the necessary Web Services files:

For example, to provide an EJB-exposing method as a Web Service, a developer creates a webservices.xml file packaged in EJB-JAR's META-INF directory. WsGen automatically creates a configured Web Application (using an Axis servlet) and wraps it (ejbjar + webapp) in an EAR file.

With a JaxRpc class, WsGen adds a servlet (an Axis servlet) inside the existing web deployment descriptor and generates an Axis-specific configuration file.

When using service-ref (from EJB-JARs, Web Applications, or clients), WsGen automatically generates a stub from WSDL (if a generated service interface name is provided).

29.4.1. Usage

WsGen is used usually from an ant build file. Simply add this taskdef under the EJB-JAR taskdef:

<taskdef name="wsgen" classname="org.objectweb.jonas.ant.WsGenTask"
   classpath="${jonas.root}/lib/common/ow_jonas_ant.jar" />
<wsgen srcdir="${temp.dir}" 
   destdir="${dist.dir}" 
   verbose="false"
   debug="false">
      <include name="webapps/wswarsample.war"/>
</wsgen>

See the $JONAS_ROOT/examples/webservices samples for complete build scripts.

Note that the EJB-JAR/Web Application/client archive must include WSDL, jax-rpc-mappings used in service-ref, or webservices.xml. When these files are used from a service-ref, they are added into the generic EJB-JAR with the EJB-JAR Ant task of JOnAS; you must ensure that they have been placed inside the srcdir given to the EJB-JAR task (otherwise, the EJB-JAR task cannot find them and will produce an error).

This task is a directory-based task and, as such, forms an implicit fileset (see http://ant.apache.org/manual/index.html. This defines which files, relative to the srcdir, will be processed. The WsGen task supports all the attributes of fileset to refine the set of files to be included in the implicit fileset.

AttributeDescriptionRequired
srcdirDirectory where file archive (EJB-JAR, WAR, Client, EAR) can be found.Yes
destdirDirectory where generated files will be placedNo
verboseVerbose mode (Defaults to false)No
debugDebug mode (Defaults to false)No
javacoptsList of options given to the Java compilerNo
jonasrootDirectory where JOnAS is installedNo
jonasbaseDirectory where JOnAS configuration is storedNo

Table 29-1. wsgen Task Support

Wsgen is also usable from the command line with WsGen script (available on *nix and Windows).