Here are a few best practices for developing an EJB Web service:Read more: Turn EJB components into Web services
- Avoid overusing Web services in your applications. Examine whether you really need to expose your EJB as a Web service.
- Use a coarse-grained session façade that encapsulates your business logic to be used as a Web service. Avoid exposing all your application's session beans as Web services.
- Examine properly whether you need either RPC-style or document-style Web services. RPC-style Web services are more efficient than document-style Web services. On the contrary, document style is more flexible because you can use schema.
- Make sure you design your Web service so that it creates minimal network traffic.
- Avoid maintaining any kind of state information in your EJB components that you expose as Web services.
- Use JAX-RPC data types as the method parameters for your Web service to give it interoperability with heterogeneous Web services. Avoid types such as Collection, HashMap, and Lists as parameters for your Web service if interoperability is important for your application.
- Many of the conventional best practices for J2EE applications (Web applications) are also relevant to EJB Web services. For example, avoid exposing an EJB component that involves long-running transactions as a Web service.
- Weigh your security requirements against performance, because security comes with a higher cost. The performance costs of end-to-end security are high.