WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

Re: [Xen-API] Java XML RPC with Xen-API?

On Mon, Apr 02, 2007 at 11:21:58PM -0400, Stefan Berger wrote:

> Ewan Mellor <ewan@xxxxxxxxxxxxx> wrote on 04/02/2007 05:40:26 PM:
> 
> > On Mon, Apr 02, 2007 at 03:37:17PM -0400, Stefan Berger wrote:
> >
> > > Evan Bigall <evan.bigall@xxxxxxxxxxx> wrote on 04/02/2007 01:50:40 PM:
> > >
> > > > My "execute" method returns result.get("Value"), you should then be
> able
> > > > to cast that into a java Set, and iterate through all the key/value
> > > pairs.
> > >
> > > I would hope so, too, but it results in a ClassCastException. Which
> XML
> > > RPC library are you using and what version?
> >
> > Glancing through the Apache XML-RPC library, version 3, it looks
> > like you should
> > either be able to cast that to either an Object [], or failing that, a
> > List.  Xen-API's Sets are marshalled as XML-RPC <array>s on the wire,
> and
> > it's up to the client library how to interpret that.
> >
> > If you call getClass() on the result, you can see what it's giving you
> > back.
> >
> 
> Here is what is coming back:
> 
> This first one is for estblishing the session -- works
> 
> -->{Status=Success, Value=7f0a5d0b-c0ff-f948-36e5-cbad03caf24c}
> UUID: 7f0a5d0b-c0ff-f948-36e5-cbad03caf24c
> 
> The VM.get_all returns a 'Set' -- only an Object comes back
> 
> Calling VM.get_all(7f0a5d0b-c0ff-f948-36e5-cbad03caf24c,...)
> Returned object = {Status=Success, Value=[Ljava.lang.Object;@1faba46}
> 'Value' has type class [Ljava.lang.Object;

[Ljava.lang.Object means an Object[].  This is what I would expect.  Each
element in that will be a String, so you will have to cast Value to Object [],
and then cast each element in that array to String (because object references
are strings on the wire).

Ewan.

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api