Hi Everyone.
I have a question on calling an EJB from a Web Service.
Is this the correct way of calling a EJB out of a web service?
We have another implementation with the same flow, and it's not calling some of the methods, unless we add @TransactionAttribute on the mehod.
I've read some of the articles for adding a transaction attribute, but what I do not understand is that sometimes it work without the attribute and sometimes we need to add the attribute.
Our entry point is the web service and from there we call the local ejb methods.
Here is the example:
1. The Web Service
@WebService()
@Stateless()
public class HouseWS {
@EJB
private PeopleLocal people;
/**
* Web service operation
*/
@WebMethod(operationName = "sayHallo")
public void sayHallo() {
//TODO write your implementation code here:
people.doPeople();
}
}
2. The Local EJB
@Local
public interface PeopleLocal {
public void doPeople();
}
3. The Bean
@Stateless
public class People implements PeopleLocal {
public void doPeople() {
System.out.println("do the people local bean");
}
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
}