[one-users] RPCXML response problem

Giuseppe Carella cargius at gmail.com
Mon May 2 03:34:25 PDT 2011


It works!

in the web site example there is not this cast:

                Object untypedResult=null;
try {
untypedResult = client.execute( "one.vmpool.info", params );
} catch (XmlRpcException e) {
e.printStackTrace();
}
 Object[] result = (Object[]) untypedResult;

Thank you Joey,

Best,

Giuseppe

2011/5/2 Joey Ma <majunjiev at gmail.com>

> Hi,
>
> Maybe you should cast the returned type of Object to the OneResponse, "One
> Response result = (OneResponse)client.execute( "one.vm.allocate", params )
> ;".
> The java unit testing source code in java oca, located in
> ./src/oca/java/test, may helps you understanding the usage of  java methods
> for xml-rpc calling.
>
> Best Regards,
> Joey
>
> On Mon, May 2, 2011 at 5:57 PM, Giuseppe Carella <cargius at gmail.com>wrote:
>
>> Hi all,
>>
>> I have a problem with XMLRPC API using it with JAVA.
>> When I send a request to opennebula XMLRPC server, I receive
>> a response like this:
>>
>> [Ljava.lang.Object;@19968e23
>>
>> How can I extract the vid from this response object?
>>
>> I have followed all the instructions in the java example of the web site.
>>
>> public class XmlRpcTest {
>>     public static void main( String <http://www.google.com/search?hl=en&q=allinurl%3Astring+java.sun.com&btnI=I%27m%20Feeling%20Lucky> args[] ) throws Exception <http://www.google.com/search?hl=en&q=allinurl%3Aexception+java.sun.com&btnI=I%27m%20Feeling%20Lucky> {
>>         XmlRpcClient client = new XmlRpcClient( "http://localhost:2633/RPC2" );
>>         Vector <http://www.google.com/search?hl=en&q=allinurl%3Avector+java.sun.com&btnI=I%27m%20Feeling%20Lucky> params = new Vector <http://www.google.com/search?hl=en&q=allinurl%3Avector+java.sun.com&btnI=I%27m%20Feeling%20Lucky>();
>>         params.addElement("SESSION-GOLA&4H910");
>>         params.addElement("MEMORY=345 CPU=4 DISK=[FILE=\"img\",TYPE=cd]""DISK=[FILE=\"../f\"]");
>>
>>         Object <http://www.google.com/search?hl=en&q=allinurl%3Aobject+java.sun.com&btnI=I%27m%20Feeling%20Lucky> result = client.execute( "one.vm.allocate", params );
>>
>>         if ( result != null )
>>             System <http://www.google.com/search?hl=en&q=allinurl%3Asystem+java.sun.com&btnI=I%27m%20Feeling%20Lucky>.out.println( result.toString() );
>>     }}
>>
>>
>> Your help is kindly appreciated!
>>
>> thanks,
>>
>> Giuseppe
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opennebula.org
>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20110502/d820135c/attachment-0003.htm>


More information about the Users mailing list