Hi Ksenija,<div>Why don't you simply use the <a href="http://opennebula.org/documentation:rel3.0:java" class="wikilink1" title="documentation:rel3.0:java" style="font-size: 13px; color: rgb(0, 152, 195); font-family: Arial, Verdana, Geneva, Helvetica, sans-serif; line-height: 18px; text-align: left; background-color: rgb(245, 245, 245); ">Java OpenNebula Cloud API</a> that is packaged with opennebula. If there is no specific scenario, its best to use them.</div>
<div><br></div><div>Prakhar<br><br><div class="gmail_quote">On Thu, Dec 8, 2011 at 3:23 PM, Ksenija Poljak <span dir="ltr"><<a href="mailto:ksenija.poljak@altus-it.hr">ksenija.poljak@altus-it.hr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">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 style="white-space:pre-wrap">  </span>private XmlRpcClient client = new XmlRpcClient();;</div><div><span style="white-space:pre-wrap">       </span>private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();</div>

<div><span style="white-space:pre-wrap">  </span>private String session = "oneadmin:ffd775fdb8e47ebf5b68513843f31742f74118e8";</div><div><span style="white-space:pre-wrap">  </span></div>
<div><span style="white-space:pre-wrap">  </span>public OpenNebulaClient(String server_url)</div><div><span style="white-space:pre-wrap">       </span>{</div><div><span style="white-space:pre-wrap">                        </span>try{</div>
<div><span style="white-space:pre-wrap">                          </span>this.config.setServerURL(new URL(server_url));</div><div><span style="white-space:pre-wrap">                           </span>this.client.setConfig(this.config);</div>
<div><span style="white-space:pre-wrap">                  </span>}catch(MalformedURLException e){</div><div><span style="white-space:pre-wrap">                         </span>System.err.println(e);</div><div><span style="white-space:pre-wrap">                   </span>}</div>

<div><span style="white-space:pre-wrap">  </span>}<span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>public void getUserInfo(int id) throws XmlRpcException</div>

<div><span style="white-space:pre-wrap">  </span>{</div><div><span style="white-space:pre-wrap">                </span>Object[] params = {session,id};</div><div><span style="white-space:pre-wrap">          </span>try {</div>
<div>            Object[] result = (Object[])this.client.execute("<a href="http://one.user.info" target="_blank">one.user.info</a>",params);</div><div>            if(!result[0].equals(null)) {</div><div>            <span style="white-space:pre-wrap">              </span>boolean success = (Boolean)result[0];</div>

<div>            <span style="white-space:pre-wrap">              </span>String str_res = (String)result[1];</div><div>            <span style="white-space:pre-wrap">          </span>System.out.println("success="+success);</div>
<div>            <span style="white-space:pre-wrap">              </span>System.out.println("result="+str_res);</div><div>            }else{</div><div>            <span style="white-space:pre-wrap">    </span>System.out.println("success=0");</div>

<div>            }</div><div><span style="white-space:pre-wrap">              </span>}catch (XmlRpcException e) {</div><div><span style="white-space:pre-wrap">                     </span>System.err.println(e);</div>
<div><span style="white-space:pre-wrap">                  </span>//e.printStackTrace();</div><div>        }</div><div><span style="white-space:pre-wrap">   </span>}</div><div><span style="white-space:pre-wrap">        </span></div>
<div><span style="white-space:pre-wrap">  </span>public static void main(String[] args)</div><div><span style="white-space:pre-wrap">   </span>{</div><div><span style="white-space:pre-wrap">                </span>OpenNebulaClient on_client = new</div>

<div><br></div><div> OpenNebulaClient("http://server_ip:port/RPC2");</div><div><span style="white-space:pre-wrap">                </span>try{</div><div><span style="white-space:pre-wrap">                     </span>on_client.getUserInfo(0);</div>

<div><span style="white-space:pre-wrap">          </span>}catch(XmlRpcException xmlrpce){</div><div><span style="white-space:pre-wrap">                 </span>System.err.println(xmlrpce);</div><div><span style="white-space:pre-wrap">             </span>}</div>

<div><span style="white-space:pre-wrap">  </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" target="_blank">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 style="white-space:pre-wrap">       </span>at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)</div>

<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)</div><div><span style="white-space:pre-wrap">    </span>at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)</div>

<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)</div><div><span style="white-space:pre-wrap">   </span>at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)</div>

<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)</div><div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)</div>

<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)</div><div><span style="white-space:pre-wrap">  </span>at open.nebula.client.OpenNebulaClient.getUserInfo(OpenNebulaClient.java:30)</div>

<div><span style="white-space:pre-wrap">  </span>at open.nebula.client.OpenNebulaClient.main(OpenNebulaClient.java:49)</div></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div>