This article shows you how to deploy an EJB application, and more. Picking up where the previous article left off, it is the third of three parts. It is excerpted from chapter 7 of the book Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, written by Steve Graham et al. (Sams; ISBN: 0672326418).
Deploying an EJB Application - JSR109 Client Code (Page 4 of 4 )
Another aspect of JSR109 is the support for managing clients, which would have helped with the test client we wrote earlier. JSR109 allows any managed Web service client to be configured outside the code. In the same way that references to datasources, EJBs, URLs, and so on can be managed by the container, 109 also supports this for service-refs (resource refs to Web services). This works for EJBs, servlets, or J2EE application clients (known as thick or managed clients) making calls to Web services. The benefit is that a reconfiguration of the application can retarget the Web service—including changing the WSDL and the list of JAX-RPC handlers to be called (JAX-RPC handlers are components that are run outside the application logic and can modify or look at the SOAP message).
In this model, the client code would look like:
Service sps = ic.lookup("java:comp/env/
SkatesProducts sp =
JSR109/WSEE offers a well-defined way to deploy Web services into an application server. Effectively, it standardizes much of what Axis does in a J2EE environment. The benefits to the developer and deployment engineer are knowing that the applications and deployment will be portable across application servers, and some simplification—for example, the requirement to package and deploy Axis as a Web application is removed. JSR109 also offers a managed client environment that allows Web services to be referred to logically using the service-ref capability. In the future, these facilities will be enhanced by the Web Services Meta-data for Java standard (JSR181). JSR181 allows programmers to annotate their code with meta-data tags that define how the code will be deployed as a service, or use Web services.
In this chapter, we've shown how Enterprise JavaBeans can be exposed as Web services. The two approaches show that Axis can be used to expose EJBs as services, providing a way of exposing existing or newly created EJB business objects over SOAP; and that JSR109 provides a simpler, more integrated approach to exposing stateless session beans as Web services, using a DD and inbuilt J2EE 1.4 capabilities.
Using J2EE as a development environment for services adds both standardization and enhanced quality of service. However, the real benefit comes when you're building complex applications that integrate across reliable, transactional, and secure environments.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.