Hi, I'm using opennebula 3 and I'm trying to write an xmlrpc Java client.<div>I'm not able to connect my client to opennebula server.</div><div>I keep getting unauthorized exception:</div><div><br></div><div>org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Unauthorized</div>
<div><br></div><div>My testing program:</div><div><br></div><div><div>package open.nebula.client;</div><div><br></div><div><br></div><div>import java.net.MalformedURLException;</div><div>import java.net.URL;</div><div><br>
</div><div>import org.apache.xmlrpc.XmlRpcException;</div><div>import org.apache.xmlrpc.client.XmlRpcClient;</div><div>import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;</div><div><br></div><div>public class OpenNebulaClient{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>private XmlRpcClient client = new XmlRpcClient();;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>private String session = "oneadmin:ffd775fdb8e47ebf5b68513843f31742f74118e8";</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>public OpenNebulaClient(String server_url)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>try{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>this.config.setServerURL(new URL(server_url));</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>this.client.setConfig(this.config);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}catch(MalformedURLException e){</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>System.err.println(e);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>public void getUserInfo(int id) throws XmlRpcException</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>Object[] params = {session,id};</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div>
<div> Object[] result = (Object[])this.client.execute("<a href="http://one.user.info">one.user.info</a>",params);</div><div> if(!result[0].equals(null)) {</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>boolean success = (Boolean)result[0];</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>String str_res = (String)result[1];</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("success="+success);</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("result="+str_res);</div><div> }else{</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("success=0");</div>
<div> }</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}catch (XmlRpcException e) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>System.err.println(e);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>//e.printStackTrace();</div><div> }</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void main(String[] args)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>OpenNebulaClient on_client = new</div>
<div><br></div><div> OpenNebulaClient("http://server_ip:port/RPC2");</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>try{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>on_client.getUserInfo(0);</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}catch(XmlRpcException xmlrpce){</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>System.err.println(xmlrpce);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div>}</div></div><div><br></div><div><br></div><div>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: <a href="http://one.user.info">one.user.info</a>.</div>
<div>Session string I used consists of username:password that I get listed with command: 'oneuser show 0' on opennebula server.</div><div>Client and opennebula server are on different machines.</div><div>I'm not sure what I do wrong. Any suggestions would be more than helpfull. Tnx in advance.</div>
<div><br></div><div>the full stackTrace of error:</div><div><br></div><div><div>org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Unauthorized</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>at open.nebula.client.OpenNebulaClient.getUserInfo(OpenNebulaClient.java:30)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>at open.nebula.client.OpenNebulaClient.main(OpenNebulaClient.java:49)</div></div>