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 EJB class. The following example illustrates how to do this:
package net.ensode.javaee8book.ejbws;
import javax.ejb.Stateless;
import javax.jws.WebService;
@Stateless
@WebService
public class DecToHexBean {
public String convertDecToHex(int 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 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 to be deployed in a JAR file.
Just like standard web services, WSDL URLs for EJB web services depend...