This feature allows a stateless session bean to be invoked using standard Web services protocols, specifically XML-based web service invocations using WSDL 1.1 and SOAP 1.1 over HTTP 1.1 in conformance with the requirements of the JAX-RPC specification.
To expose a stateless session bean as a Web service, you must:
Define a Web service endpoint interface that satisfies the requirements described below.
Declare the endpoint interface in the deployment
descriptor using a service-endpoint
element.
The Web service endpoint interface defines the methods in the bean that can be invoked by Web services clients. Each method in the endpoint interface describes a Web service operation to be exposed in the WSDL interface for the Web service.
The mapping of EJB methods to WSDL interface operations is based on the JAX-RPC specification. Specifically, the Bean implementation and interface must satisfy these requirements:
The endpoint interface must extend the java.rmi.Remote interface.
The methods in the endpoint interface must follow the rules for JAX-RPC service endpoint interfaces. Specifically:
Their argument and return values must be of valid types for JAX-RPC, and their throws clause must include java.rmi.RemoteException (in addition to the application exceptions to match those thrown by the equivalent bean implementation method).
You cannot pass references to the bean instance, other beans, or other object references that are not valid outside the scope of the bean’s implementation. These references include EJB instance references (class EJBObject), EJB local instance references (EJBLocalObject), timer and timer handle references, local, remote, home, and local home classes, and managed collections that are used for entity beans with container-managed persistence. These types cannot be used as a parameter, return type, or in arrays or complex types used as parameters and return types.
To support WSDL output and input-output operations, use JAX-RPC holder classes. Holder classes implement the javax.xml.rpc.holders.Holder interface.
The web service endpoint interface must not include
constant (as public final static
)
declarations.
The bean implementation class must contain an equivalent method for each method in the endpoint interface. The methods must have the same name, take the same argument list, and return the same type. The service interface method must throw all exceptions listed in the throws clause of the implementation method (in addition to java.rmi.RemoteException).