[英]How to make access based xmlrpc call for ejabberd from Java client?
我正在ejabberd和ejabberd_xmlrpc模塊- https://www.ejabberd.im/ejabberd_xmlrpc在鏈接我可以看到訪問控制Python和PHP和XML-RPC客戶端模塊。 我們如何使用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);
}
但是它提供了一個未知的呼叫記錄。
通過將第一個結構中的主機更改為服務器來修復它。 我的錯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.