Develop a Service Endpoint Interface from an EJB remote interface

Set up a Web services development and unmanaged client execution environment.

The Service Endpoint Interface defines the Web services methods. The enterprise JavaBean (EJB) that implements the Web service must implement methods having the same signature as the methods of the Service Endpoint Interface. There are a number of restrictions on which types to use as parameters and results of Service Endpoint Interface methods. These restrictions are documented in the Java API for XML-based remote procedure call (JAX-RPC) specification, which is available through Web services: Resources for learning.

The easiest method for creating the Service Endpoint Interface for an EJB Web service implementation is from the EJB remote interface.

You can also create a Service Endpoint Interface by using the Assembly Toolkit, which is a component of the Application Server Toolkit. The steps are similar except the Assembly Toolkit automatically compiles the interface when you save it. To develop a Service Endpoint Interface...

  1. Create a Java interface containing the methods to include in the Service Endpoint Interface.The interface should extend the java.rmi.Remote interface. Each method throws the exception, java.rmi.RemoteException. If you start with an existing Java interface, remove any methods that do not conform to JAX-RPC.

  2. Compile the interface. Use the javac commands for Windows and UNIX platforms listed in the topic Developing thin application client code to compile the interface. In the javac command, use the name of the Service Endpoint Interface class for the class to be compiled.

A Service Endpoint Interface which you can use to develop a Web service.

 

Usage scenario

package addr;
public interface AddressBook_RI extends javax.ejb.EJBObject {
    /**
     * Retrieve an entry from the AddressBook.
     * 
     *@param name the name of the entry to look up.
     *@return the AddressBook entry matching name or null if none.
     *@throws java.rmi.RemoteException if communications failure.
     */
    public addr.Address getAddressFromName java.lang.String(name) 
        throws java.rmi.RemoteException;
}
AddressBook_RI

  1. Begin with the remote interface, AddressBook_RI.java...

  2. Make a copy of the remote interface named AddressBook.java and use it as a template for the Service Endpoint Interface.

  3. Change the interface to extend the java.rmi.Remote interface, instead of the javax.ejb.EJBObject Service Endpoint Interface.

  4. Compile the AddressBook.java Service Endpoint Interface.

Use the Service Endpoint Interface to Develop a WSDL file.

 

See Also

Developing a Web service using a stateless session enterprise bean
Artifacts used to develop Web services based on Web Services for J2EE