I am currently trying to wrap my mind around Java EE 5. What I'd like to do is create a sample application that
- offers a simple stateless EJB (e. g. a simple calulator with an add() method)
- expose this add method as a webservice
- consume this webservice from another EJB
The first two steps are easy and I can deploy and test this bean to Glassfish v2.1 already and test it with a standalone client:
@WebService
@Stateless
public class CalculatorWS {
@WebMethod
public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
int k = i + j;
return k;
}
}
What I do not get however, is how to consume a webservice like this from a second EJB. While not strictly useful in this example, I will have to write some EJBs soon that will wrap external webservices as to keep my internal clients from having to deal with those external resources.
From what I understand, I should be able to have the container inject me a webservice into a field of my EJB? I did not find an example for this, however. I'd welcome any hints to tutorials covering this - or even better an example right here :-)
For what it's worth, I am using Eclipse 3.5.