University of Cincinnati logo and link  
Creating a Web Service
 
  UC ingot Creating a Web Service is surprisingly like RMI.  You must create an interface and a server class that implements that interface.
  • The similarities do not end there.  The interface must extend java.rmi.Remote, and its methods must throw java.rmi.RemoteException.
  • After developing the interface and implementation classes, run the mapping program to generate the stub and tie classes, WSDL, and any other needed classes.
    • Then, we'll need to make a Web Application Archive, or WAR file, to deploy our web service.
    • Our WAR file must have deployment descriptor, or web.xml file, as well.  This is nothing new, though.  When we deploy in Tomcat we us a web.xml file.
      • Our web.xml file must reference the .properties file generated by the mapping tool.
    • Once we have the WAR file, we can simply copy it to Tomcat's webapps directory for deployment.  Tomcat will take care of the rest.
 Making the Client, Calling a Remote Method 

/* 
 * Chat.java 
 * 
 * Created on April 28, 2003, 11:55 PM 
 */ 
package chat; 

import java.rmi.*; 

/** Remote interface. 
 * 
 * @author default 
 * @version 1.0 
 */ 
public interface Chat extends java.rmi.Remote { 

    public void login (String user, String password) throws RemoteException; 
  
    public void sendMessage (String message, String user) throws RemoteException;