Exposing Enterprise Beans as web services
In addition to creating web services as described in the previous section, public methods of stateless session beans can easily be exposed as web services by simply adding an annotation to the Enterprise Bean class. The following example illustrates how to do this:
package com.ensode.jakartaeebook.jebws; import jakarta.ejb.Stateless; import jakarta.jws.WebService; @Stateless @WebService public class DecToHexBean { public String convertDecToHex(Integer i) { return Integer.toHexString(i); } }
As we can see, the only thing we need to do to expose a stateless session bean’s public methods as web services is to decorate its class declaration with the @WebService
annotation. Needless to say, since the class is a session bean, it also needs to be decorated with the @
Stateless
annotation.
Just like regular stateless session beans, the ones whose methods are exposed as web services need...