Infatti anche a me sembrano corrette e credo l'errore sia da un'altra parte, anche il tipo di ritorno Object poi mi rimane scomodo. Posto tutto il metodo:
codice:
public Object execute(XmlRpcRequest request) throws XmlRpcException{
if (request.getMethodName().equals("newData" ) ||
request.getMethodName().equals("add_name" ) ||
request.getMethodName().equals("average_name" ) ||
request.getMethodName().equals("min_name" ) ||
request.getMethodName().equals("max_name" ) ||
request.getMethodName().equals("merge" ) ||
request.getMethodName().equals("reset" ) )
{
if (request.getMethodName().equals("newData")) {
String name=request.getParameter(0).toString();
return newData(name);
}
if (request.getMethodName().equals("add_name")) {
String name=request.getParameter(0).toString();
// Integer valore=new Integer(((Integer) request.getParameter(1)));
return add_name(name,valore);
}
if (request.getMethodName().equals("average_name")){
return average_name();
}
if (request.getMethodName().equals("min_name")) {
return min_name();
}
if (request.getMethodName().equals("max_name")) {
return max_name();
}
if (request.getMethodName().equals("merge")) {
String x=request.getParameter(0).toString();
String y=request.getParameter(1).toString();
String z=request.getParameter(2).toString();
merge(x,y,z);
}
if (request.getMethodName().equals("reset")) {
return reset();
}
}
else {
throw new XmlRpcException("Il metodo non esiste!");
return null;
}
}
e il client invoca i metodi con
codice:
....
Object []params = new Object []{new String("test analisi"),new Integer(20)};
try
{
Object result = client.execute("newData", params );
System.out.println("The result is: "+result+".");
}
catch(Exception ex)
{
System.err.println("Error: " + ex.getMessage());
}
Quello che dicevi te sul valore che poteva non essere un Integer a runtime mi torna ,ma siccome lo passo io e sono sicuro che è integer dovrebbe andare bene.
Il metodo newdata ritorna un boolean è quindi ci vuole anche un cast nel client, ma quello va bene lo faccio dopo, piu che altro mi interessa capire perche quel metodo execute non va..