2006-01-10
| Table of Contents: |
| Rate This Article: | Add This Article To: |
( Page 3 of 3 )
Generate EJB (Target Name: generate)
This step in the build file calls upon XDoclet to generate all of the interface files for our EJBs. It also produces the JBoss specific descriptors needed to deploy the EJBs. This step finds all the message beans, session beans, and entity beans that we defined in the project, and produces the appropriate interface files in the 'gen' directory.
Compile (Target Name: compile)
This step is normal in a build file, but a minor change is required in that we have more than one source tree.
Generate WSDL (Target Name: wsdl)
This step produces the wsdl file needed by SOAP to make the service available. Currently, there is no way to generate this file using XDoclet (although I suspect it will be available very soon), so we use the command line tool that comes with JBoss to produce this file.
This is the only truly hard-coded part of the build file. Because we need to use the command line tool (not anything that is dynamic, like XDoclet), we need to specify a few parameters inside the build file.
Generate WSEE (Target Name: wsee)
This step produces the JAX-RPC mapping file as well as the webservices.xml file needed by JBoss to publish the SOAP service. In the near future, this step will also produce the WSDL file; but at this time that functionality is too limited.
Create EJB JAR (Target Name: jar)
This step is part of the normal build flow for a Java project, but we included additional steps for the SOAP definition files. Specifically: the wsdl file, webservices.xml file, and JAX-RPC Mapping file are placed in the META-INF directory of the JAR. Note that the wsdl file is placed in a sub directory under META-INF, as required by JBoss.
Create EJB EAR (Target Name: ear)
This step is also part of the normal build flow for an EJB application. The only change here is a specific exclusion of the SOAP definition files.
Deployment and the Magic
Deploying this application is as simple as typing ant ear at the command line, and watching Ant/XDoclet do all of the work for us. Ant produces all of the required files and places them in the ear file for deployment.
Once the ear is complete, we simply place it in JBoss' deploy directory and fire up the server. Once the server has completed, at start up you should see the following lines in the log:
[WSDLFilePublisher] WSDL published to: file:/opt/.jboss-4.0.1sp1/server/default/data/wsdl/example.ear/example.jar/example.wsdl [AxisService] WSDD published to: /opt/.jboss-4.0.1sp1/server/default/data/wsdl/example.ear/example.jar/Hello.wsdd [AxisService] Web Service deployed: http://localhost:8080/example/example/Hello
To access the service, point your browser at:
http://localhost:8080/example/example
...and you will see a web page similar to Figure 2.
The service is now online and available for use via any SOAP Client.
In this article, I showed how to utilize a Stateless Session Bean directly via SOAP and avoid a sometimes unnecessary web module. This removes an additional layer of abstraction from an already complicated EJB Application, and yet provides full access to that application via any language that supports SOAP.
This implementation also allows you to use EJB Security to authenticate the SOAP request and provide a single point of security for the entire application.
![]() |
|


