2 Replies Latest reply on Mar 20, 2007 10:29 PM by monowai

    Why interface for EJB3 webservices?

    zauberlehrling

      Hi,

      I'm investigating your examples in jbossws-samples-1.2.0.SP1.
      In your example for EJB3 webservices you use two classes:

      1) An interface (EJB3RemoteInterface)
      2) The stateless session bean implementing the operation of the webservice (EJB3Bean01)

      ..
      // standard JSR181 annotations
      @WebService(name = "EndpointInterface", targetNamespace = "http://org.jboss.ws/samples/jsr181ejb", serviceName = "TestService")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      
      // standard EJB3 annotations
      @Remote(EJB3RemoteInterface.class)
      @RolesAllowed("friend")
      @Stateless
      
      // jboss propriatary annotations
      @RemoteBinding(jndiBinding = "/ejb3/EJB3Bean01")
      @WebContext(authMethod="BASIC", transportGuarantee="NONE", secureWSDLAccess=false)
      @SecurityDomain("JBossWS")
      public class EJB3Bean01 implements EJB3RemoteInterface
      {
       @WebMethod
       @WebResult(name = "result")
       public String echo(@WebParam(name = "String_1") String input)
       {
       return input;
       }
      }

      I also have a small session bean / webservice :
      @WebService
      @Stateless
      public class EjbEndpoint {
      
       @WebMethod
       public String sayHello(String name)
       {
       return "Hello "+name+"!";
       }
      }

      and I can successfully deploy this session bean / webservice to jboss-5 Beta 2. Even I am able to call the webservice.

      My question: What's the purpose of the interface? Have I missed something?

      Thanks in adavance!

      Frank

        • 1. Re: Why interface for EJB3 webservices?
          monowai

          The interface is not strictly required under EJB3 and your question has nothing to do with Webserices per-se.

          The reason for a Remote Interface is just that - Remote (or client). If you don't distribute a remote interface, then you have to distribute your EJB's. Deploying server side logic is a no-no in my book.

          So, to sum up, if you expect a remote client to use RMI to call your EJB's, then create and distribute a remote interface.

          • 2. Re: Why interface for EJB3 webservices?
            monowai

             

            "monowai" wrote:
            ...Deploying server side logic is a no-no in my book..

            Should have read:
            Deploying Service side logic to the Client!