How Can I access a Stateful Session Bean with a WebService ?
Hello,
Here is my problem: I need to access my session bean with a web service endpoint, but I need to keep track of my session bean instance each time I call my Web Service.
As I can only use annotation @WebService with a Stateless bean (@Stateless) as an example I tried something like that:
[code]
@WebService()
public class NewWebService {
@EJB
private NewSessionLocal newSessionBean;
/**
* Web service operation
*/
@WebMethod
public String operation() {
return newSessionBean.hello();
}
}
@Stateful
public class NewSessionBean {
private String message;
/** Creates a new instance of NewSessionBean */
public NewSessionBean() {
message = "";
}
public String hello(){
return message += "hello";
}
}
[code]
which should append hello string every time I call my web Service. However it only works if I remove annotation @EJB and @Stateful. Otherwise I get an
EJB5070: Exception creating stateless session bean : [{0}]
If someone could help me on this it would be nice.
On another point I also tried with JAX-WS 2.1 "stateful web service" but I don't see how I can link this class with my ejb3 entity beans (which mapp into my database...) as it has to be in a war module and my ejb are in ejb module (is JAX-WS 2.1 compatible with ejb3?).
I also tried with HttpSession but it doesn't work either.
Any solution : keeping the data of my session bean for different calls of my web service would be good to me
Thank you

