我正在运行ejabberd和ejabberd_xmlrpc模块- xmlrpc链接中,我可以看到python、php和xmlrpc客户端模块具有访问控制。我们如何使用java客户端编写相同的代码?
这是我的代码:
/* Code for ejabberd */
try {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://ejabberd.sandwitch.in:4560"));
config.setBasicUserName("nishant@ejabberd.sandwitch.in");
config.setBasicPassword("freebsd");
config.setConnectionTimeout(xmlrpcConnTimeout);
config.setReplyTimeout(xmlrpcReplyTimeOut);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
/* Command string */
String command = "register";
/* Parameters as struct */
Map struct = new HashMap();
struct.put("user", "nishant");
struct.put("host", "ejabberd.sandwitch.in");
struct.put("password", "nishant");
Map struct1 = new HashMap();
struct1.put("user", "arbit6");
struct1.put("host", "ejabberd.sandwitch.in");
struct1.put("password", "arbit6");
Object[] params = new Object[]{struct, struct1};
HashMap<Object, Object> hashMap = (HashMap<Object, Object>) client.execute(command, params);
for (Object obj : hashMap.keySet()) {
System.out.println(ToStringBuilder.reflectionToString(obj));
}
for (Object obj : hashMap.values()) {
System.out.println(ToStringBuilder.reflectionToString(obj));
}
System.out.println(ToStringBuilder.reflectionToString(hashMap.get("text")));
} catch (Exception e) {
System.out.println(e);
}
但它提供了一个未知的呼叫寄存器。
发布于 2015-10-13 09:42:12
通过将第一个struct中的主机更改为服务器来修正它。是我的错。
https://stackoverflow.com/questions/33097883
复制相似问题