1 Reply Latest reply on Nov 5, 2008 5:00 AM by johanpersson

    EJB client for a Web service

    rrrrr rrrr Newbie

      Hi all!
      I'm trying to use an EJB as client for a Web service. Unfortunately I'm having some problems when I'm injecting the WebServiceRef into the EJB.

      Here's my code:
      This is the WebService in the .war file :

      @WebService
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      public class POJOWs implements POJOWsItf
      {
      
       @WebMethod
       public String echo(String input)
       {
       return input + " called !";
       }
      }


      This is the EJb in the jar file:

      @Stateless
      
      public class EJBClient implements EJBClientItf {
      
      
       @WebServiceRef(POJOWs.class)
       private POJOWs service;
      
       public String callWS(String input) {
      
       System.out.println("EJB called !");
       return service.echo(input);
      
      
       }
      }


      Now when I try to lookup my EJb and invoke the method callWS :

      <%
       InitialContext ctx = new InitialContext();
       com.sample.EJBClientItf ejb = null;
       ejb = ( com.sample.EJBClientItf)ctx.lookup("StatelessfulExample/EJBClient/remote");
       String ss = ejb.callWS("hello");
       out.println(ss);
      
      %>



      Here's the error I get:

      javax.ejb.EJBException: java.lang.RuntimeException: Unable to inject jndi dependency: env/com.sample.EJBClient/service into property com.sample.EJBClient.service: WebServiceRef type 'class com.sample.POJOWs' is not assignable to javax.xml.ws.Service

      How can I fix it ?
      thanks a lot
      john