+

Search Tips   |   Advanced Search

 

Develop a service endpoint interface from an EJB

 

You can develop a service endpoint interface from an Enterprise JavaBeans (EJB) for a JAX-RPC Web service. Set up a development environment for Web services.

This task is a required step in developing a Java API for XML-based RPC (JAX-RPC) Web service from an enterprise bean.

The service endpoint interface defines the Web services methods. The enterprise beans that implements the Web service must implement methods having the same signature as the methods of the service endpoint interface. A number of restrictions exist 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 tools.

 

Overview

Develop a service endpoint interface by following the steps provided in this task section.

 

Procedure

  1. Create a Java interface that contains the methods to include in the service endpoint interface. If you start with an existing Java interface, remove any methods that do not conform to the JAX-RPC specification.

  2. Compile the interface.

    Use the name of the service endpoint interface class in the javac command for the class to compile.

    On Windows use the javac commands.

    [AIX HP-UX Solaris] Use the Linux and Unix platforms cited in Developing thin application client code.

 

Results

You have a service endpoint interface used to to develop a Web service.

 

Example

This example uses the EJB remote interface, AddressBook_RI, to create a service endpoint interface for an EJB implementation that is used as a Web service. The following code example illustrates the AddressBook_RI remote interface.

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;
}
Use the following steps to create the service endpoint interface with the AddressBook_RI remote interface:

  1. Locate a remote interface that has already been created, like the AddressBook_RI.java remote interface.

  2. Make a copy of the AddressBook.java remote interface and use it as a template for the service endpoint interface.

  3. Compile the AddressBook.java service endpoint interface.

 

What to do next

Continue gathering the artifacts that are required to develop a Web service, including the Web Services Description Language (WSDL) file. We need to develop a WSDL file because it is the engine of a Web service; without a WSDL file, you have no Web service.



Developing Web services applications from enterprise beans

 

Related Reference


Artifacts used to develop Web services