如何从 Java 客户端对 ejabberd 进行基于访问的 xmlrpc 调用?
How to make access based xmlrpc call for ejabberd from Java client?
我是 运行 ejabberd 和 ejabberd_xmlrpc 模块 - https://www.ejabberd.im/ejabberd_xmlrpc
在 link 中,我可以看到 python、php 和带有访问控制的 xmlrpc 客户端模块。我们如何使用 java client
编写相同的内容
这是我的代码:
/* 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);
}
但是它正在给一个未知的呼叫注册。
通过将第一个结构中的主机更改为服务器来修复它。我的错。
我是 运行 ejabberd 和 ejabberd_xmlrpc 模块 - https://www.ejabberd.im/ejabberd_xmlrpc 在 link 中,我可以看到 python、php 和带有访问控制的 xmlrpc 客户端模块。我们如何使用 java client
编写相同的内容这是我的代码:
/* 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);
}
但是它正在给一个未知的呼叫注册。
通过将第一个结构中的主机更改为服务器来修复它。我的错。