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 !"; } }
@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); } }
<% 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); %>
Is the jndi name present in JNDIView in JMXConsole ?
Does EJBClientItf annotate @Remote ?
If you like you can extend your Web Service with a remote interface also, making EJBClient redundant ?
@Remote public interface POJOWsItf