I am running ejabberd and ejabberd_xmlrpc module - https://www.ejabberd.im/ejabberd_xmlrpc In the link I can see python, php and xmlrpc client module with access control. How can we write the same using java client
Here is my code:
/* 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);
}
But it is giving an unknown call register.