XML-RPC with java

I am developing a server in XML-RPC using Java but when I compile it I get this error

ServeurSomDiff.java:33: cannot find symbol
symbol  : method addHandler(java.lang.String,java.lang.String)
location: class org.apache.xmlrpc.webserver.WebServer
                server.addHandler("SOMDIFF",new ServeurSomDiff ());

      

here's my server:

import java.util.Hashtable;
import org.apache.xmlrpc.webserver.*;
public class ServeurSomDiff {
public ServeurSomDiff (){ 
}
    public Hashtable sumAndDifference (int x, int y) {
        Hashtable result = new Hashtable();
        result.put("somme", new Integer(x + y));
        result.put("difference", new Integer(x - y));
        return result;
      }
      public static void main (String [] args) {
        try {
                   WebServer server = new WebServer(8000);
           server.addHandler("SOMDIFF",new ServeurSomDiff()); 
   server.start(); 
   System.out.println("Serveur lance sur http://localhost:8000/RPC2");  
       } catch (Exception exception) 
       {System.err.println("JavaServer: " + exception.toString());
             }
           }
        }

      

any ideas on how to fix this. thanks

+2


a source to share


4 answers


You need to set the display of adler. Using the javadoc web server as an example:

   XmlRpcServer server = webServer.getXmlRpcServer();
   server.setConfig(config);
   server.setHandlerMapping(mapping);

      



Check http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/PropertyHandlerMapping.html for a possible suitable implementation.

+3


a source


According to the documentation, there is no such method as "addHandler". Perhaps you meant a different class or a different method?



0


a source


make sure the two xml-rpc jar files are in the same directory as the written java files before compiling. 1- xmlrpc-1.2-b1 2- xmlrpc-1.2-b1-applet

here is the link http://compsci.ca/v3/viewtopic.php?t=2039 http://compsci.ca/v3/download.php?id=612

put this in the same folder with the server file and compile it

java -cp .; lib * NameOfServer.java

0


a source


I also had a similar problem in my project. The problem is that you are using the version 3 xmlrpc jar and using the version 2. code download the jar from the following link then your code should work. http://www.java2s.com/Code/Jar/x/Downloadxmlrpc201jar.htm

0


a source







All Articles