How to use a web service from EJB

I'm currently trying to think about Java EE 5. What I would like to do is create an example application that

  • offers a simple unscreened EJB (for example, a simple calculator with the add () method)
  • set this add method as a web service
  • consume this web service from another EJB

The first two steps are simple, and I can deploy and test this bean on Glassfish v2.1 already and test it using 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 am not getting is how to use such a web service from the second EJB. Although this is not very useful in this example, I will need to write some EJBs soon that will cover external web services so that my internal clients cannot deal with these external resources.

, , - EJB? . , , : -)

, Eclipse 3.5.

+3
3

Java EE

-

+2

- EJB. , JAX-WS, EJB (JNDI .. ).

, WebSphere, , , here, .

-1

I would just introduce this Bean calculator to another stateless Bean with @EJB. Just make sure your Bean implements some kind of interface that you can embed.

-1
source

Source: https://habr.com/ru/post/1715160/


All Articles