Reputation: 1
I m trying to get the response of get_roster
in ejabberd through XML-RPC client but I am using ejabberd 18.9 version and it is showing me this error:
org.apache.xmlrpc.XmlRpcException: Error -118 A problem '{error,access_rules_unauthorized}' occurred executing the command get_roster with arguments [{user,<<"admin">>},{server,<<"localhost">>}]
Can somebody suggest how can I solve this?
Here is my java client code:
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://localhost:4560"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Hashtable<String, Object> params = new Hashtable<String, Object>();
params.put("user", new String("admin"));
params.put("server", new String("localhost"));
List<Object> roster_params = new ArrayList<Object>();
roster_params.add(params);
Object result = client.execute("get_roster", roster_params);
System.out.println("Result: " + result);
Upvotes: 0
Views: 891
Reputation: 1
the issue is now resolved there was some issue with the ejabberd.yml file. I enabled outh configurations after removing this in config file now this codes works...
port: 5280 ip: "::" module: ejabberd_http request_handlers: "/ws": ejabberd_http_ws "/bosh": mod_bosh "/api": mod_http_api
Upvotes: 0
Reputation: 4120
Probably you have ejabberd configured in a way that you must provide auth details of an account with admin rights. In this example written in python, see the LOGIN structure. Sorry, I don't know how this is done in Java.
import xmlrpclib
server_url = 'http://127.0.0.1:4560'
server = xmlrpclib.ServerProxy(server_url)
LOGIN = {'user': 'admin', 'server': 'localhost', 'password': 'mypass11', 'admin': True}
def calling(command, data):
fn = getattr(server, command)
return fn(LOGIN, data)
print ""
print "Calling with auth details:"
result = calling('get_roster', {'user':'user1', 'server':'localhost'})
print result
Upvotes: 0