JAX-RPC Service-Side Programming Models

JAX-RPC defines two server-side programming models for creating J2EE Web service endpoints: JAX-PRC Service Endpoints andEnterprise JavaBeans Endpoints.  The service endpoint is deployed in a container-based JAX-RPC runtime system.
  • Using a JAX-RPC service endpoint (JSE) ? The service implementation is a Java class in the Web container. The service adheres to the Web container’s servlet lifecycle and concurrency requirements.
  • Using an EJB service endpoint? The service implementation is a stateless session bean in an EJB container. The service adheres to the EJB container’s lifecycle and concurrency requirements.
In either case, the service is made portable with the definition of a port component, which provides the service’s outside view for Web service implementation. A port component consists of:
  • A WSDL document describing the Web service that its clients can use
  • A service endpoint interface defining the Web service’s methods that are available to clients.
  • A service implementation bean implementing the business logic of the methods defined in the service endpoint interface. The implementation may be either a Java class in the Web container or a stateless session bean in the EJB container.
JAX-RPC requires the service definition interfaces must follow RMI conventions, no remote references allowed, and all objects are passed by copy.
Container-specific service interfaces, created by the J2EE container, provide static stub and dynamic proxies for all ports. A client of a J2EE platform Web service can be a Web service peer, a J2EE component, or a stand-alone application. It is not required that the client be a Web service or application implemented in Java.
Use a stateless Session Bean to expose Web services if you: 
  • Need to expose previously existing stateless Session Beans as Web services
  • Need declarative transaction management
  • Need the thread management provided by EJB Container
  • Need role based security
    Use Java classes to expose your Web services if you: 
    • Need to expose previously existing Java classes as Web services
    • Want a light-weight system, and don’t care much about transactional capabilities that an EJB container provides