Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XML-RPC server issues

843834Sep 18 2007
Hello,

The problem: my XML-RPC server is queuing up the requests. For instance, if I add a delay on the method that processes the request (see example below) and call the service again, it won't pick it up until the first one is completed.

The question: am I doing something wrong or that's the way it works? If so, is there any workaround to make the server process each request as, for example, a separate thread?

I am using Apache's XML-RPC 3.1 (tried 3.0 and same thing) with its built-in web server (not as a servlet).

Any help would be greatly appreciated.
Thanks in advance.
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;

public class Server {
    private int port;
    
    public Server( int port ) {
        this.port = port;
    }
    
    public void start() {
        
        try {
            System.out.println("XML-RPC Server starting up on port " + port);
            WebServer webServer = new WebServer(port);
            
            XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();
            PropertyHandlerMapping phm = new PropertyHandlerMapping();
            
            phm.addHandler("ServerHandler", ServerHandler.class);
            
            xmlRpcServer.setHandlerMapping(phm);
            
            XmlRpcServerConfigImpl serverConfig =
                    (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
            serverConfig.setEnabledForExtensions(true);
            serverConfig.setContentLengthOptional(false);
            xmlRpcServer.setConfig(serverConfig);
            
            webServer.start();
            System.out.println("XML-RPC Server started OK");
        } 
        catch( Exception e ) {
           e.printStackTrace();
        }
    }
    
    public static void main( String args[] ) {
        Server server = new Server(8080);
        server.start();
    }
}

class ServerHandler {
    public java.util.Hashtable send( java.util.Hashtable params ) {
        java.util.Hashtable ret = new java.util.Hashtable();
        ret.put("StatusCode", 0);
        ret.put("StatusMessage", "Success");
        ret.put("Success", true);
        System.out.println("params: " + params);
        
        try {
            Thread.sleep(5000);
        }
        catch( Exception e ){}
        
        return ret;
    }
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2007
Added on Sep 18 2007
0 comments
144 views