java - The weird behavior of Apache XML-RPC -
there issue confused me when using apache xml rpc
below code
public class adderimpl implements adder{
private object obj=new string("obj1"); public int add(int pnum1, int pnum2) { obj="changed"; return pnum1 + pnum2; } public object get(){ return this.obj; }
}
when call method client side object value still obj1, not "changed"
how can changed value of obj
client:
public class client {
public static void main(string [] args) throws exception { xmlrpcclientconfigimpl config = new xmlrpcclientconfigimpl(); config.setserverurl(new url("http://127.0.0.1:8080/xmlrpc")); config.setenabledforextensions(true); config.setconnectiontimeout(60 * 1000); config.setreplytimeout(60 * 1000); xmlrpcclient client = new xmlrpcclient(); client.settransportfactory( new xmlrpccommonstransportfactory(client)); client.setconfig(config); // make call using dynamic proxy clientfactory factory = new clientfactory(client); adder adder = (adder) factory.newinstance(adder.class); int sum = adder.add(2, 4); system.out.println("2 + 4 = " + sum); system.out.println(adder.get()==null?true:false); system.out.println(adder.get().tostring()); }
}
thanks in advance
a new handler get's created each time. obtain behaviour want have following options:
- write value database/file (i.e. persistence storage) , read/write there.
make field static, i.e.
private static object obj=new string("obj1");
hope helps.
Comments
Post a Comment