I have been reading about Stateful and Stateless session beans and came across a sentence that states that:
Stateful session beans cannot be exposed as web services.
Can anyone elaborate why ?
Every Stateful bean instance located in the EJB Container has an unique object identity.
From spec.: 184.108.40.206 Stateful Session Beans A stateful session object has a unique identity that is assigned by the container at the time the object is created.
In order to use a Stateful bean, the client code needs to get a Stateful reference from the EJB Container. This reference has to be used to make every future request. Due to the reference object knows the identity associated to the stateful bean, you can be sure that all requests that participate in the "conversation" will be resolved for the same instance bean. This means that the Client has an important role in achieving the stateful behavior.
The SOAP protocol doesn't provide a way that allow to store in a web service client this identity, therefore, if the client doesn't know which stateful instance has the conversational state, every request will be processed by different ejb (such as the case of stateless).