[one-users] xmlrpc client

Ksenija Poljak ksenija.poljak at altus-it.hr
Thu Dec 8 01:53:49 PST 2011


Hi, I'm using opennebula 3 and I'm trying to write an xmlrpc Java client.
I'm not able to connect my client to opennebula server.
I keep getting unauthorized exception:

org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned
unexpected status: Unauthorized

My testing program:

package open.nebula.client;


import java.net.MalformedURLException;
import java.net.URL;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

public class OpenNebulaClient{
private XmlRpcClient client = new XmlRpcClient();;
private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
private String session =
"oneadmin:ffd775fdb8e47ebf5b68513843f31742f74118e8";
 public OpenNebulaClient(String server_url)
{
try{
this.config.setServerURL(new URL(server_url));
this.client.setConfig(this.config);
}catch(MalformedURLException e){
System.err.println(e);
}
}
 public void getUserInfo(int id) throws XmlRpcException
{
Object[] params = {session,id};
try {
            Object[] result = (Object[])this.client.execute("one.user.info
",params);
            if(!result[0].equals(null)) {
            boolean success = (Boolean)result[0];
            String str_res = (String)result[1];
            System.out.println("success="+success);
            System.out.println("result="+str_res);
            }else{
            System.out.println("success=0");
            }
}catch (XmlRpcException e) {
System.err.println(e);
//e.printStackTrace();
        }
}
 public static void main(String[] args)
{
OpenNebulaClient on_client = new

 OpenNebulaClient("http://server_ip:port/RPC2");
try{
on_client.getUserInfo(0);
}catch(XmlRpcException xmlrpce){
System.err.println(xmlrpce);
}
}
}


I'm confused becose when I look at examples on the web, there are methods
used as one.userinfo, and on opennebula official site they are listed in
form: one.user.info.
Session string I used consists of username:password that I get listed with
command: 'oneuser show 0' on opennebula server.
Client and opennebula server are on different machines.
I'm not sure what I do wrong. Any suggestions would be more than helpfull.
Tnx in advance.

the full stackTrace of error:

org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned
unexpected status: Unauthorized
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)
at open.nebula.client.OpenNebulaClient.getUserInfo(OpenNebulaClient.java:30)
at open.nebula.client.OpenNebulaClient.main(OpenNebulaClient.java:49)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20111208/8bc95036/attachment-0002.htm>


More information about the Users mailing list