我正在编写一个 java 程序,我想在其中使用 xmlrpc 模拟与远程过程调用的客户端-服务器关系。
但是,当我尝试远程调用该方法时,我收到此错误消息:
'JavaClient: XML-RPC Consumer Fault #java.lang.ClassCastException: java.lang.String 无法转换为 java.lang.Integer'
这是客户端产生错误的方法:
public String getHashsize() {
// Execute the remote call, using the handler
try
{
argHashsize = new Vector(); //see next method for comments
argHashsize.addElement(serverURL);
// make the call
String callit = ("GetSize.sendHashSize");
sizeHash = (Integer)client.execute(callit, argHashsize );
}
// Use XmlRpcException errors
catch (XmlRpcException exception) {
System.err.println("JavaClient: XML-RPC Consumer Fault #" +
Integer.toString(exception.code) + ": " +
exception.getCause() + "" + exception.toString());
} catch (Exception exception) {
System.err.println("JavaClient: XML-RPC Consumer Fault #" + exception.toString());
}
String StrsizeHash = Integer.toString(sizeHash); // Cast sizeHash to String
return StrsizeHash;
}
这是我试图调用的方法:
public String sendHashSize(String getCaller) {
// send back info to Message Broker
sendbackserverdata = "number of staff: " + theHashtable.noStaff()
+ " Caller: " + getCaller
+ " Port: " + getServerPort()
+ " " + getSendtime();
//Store server info in Hashtable persist - could be a database
/*persist.put("" + theHashtable.noStaff(),"" + sendbackserverdata);
sendServerData = sendbackserverdata;
stats.StoreinStatsHashtable("" + theHashtable.noStaff(), sendbackserverdata);*/
return sendbackserverdata; // return to Consumer
}