>On the server, it simply depends ...
In my case I'm only writing the client code.
>The only place where the logic breaks is the clients return value: The
>XML-RPC library doesn't know what type of return value you expect. In
>other words, you should always receive an Object[] there.
I definitely see some variation. My original xmlrpc code was written to
always expect vectors, whenever the xmlrpc type was <array>. That
worked. When porting to 3.0 I recoded to expect Object[] instead and
sometimes, but not always, this produced ClassCastExceptions - the there
seemed to be a case where I got a class cast exception casting a
LinkedList as an Object[]. I had to write the following code to work
around this:
/**
* @param o an Object[] or List returned from an XML-RPC array
type
* @return a List containing the same elements as the array
* @throws ClassCastException if o is not an Object[] or a List
*/
protected static List getAsList(Object o)
{
if (o instanceof List && o != null) {
return (List) o;
}
List newlist = new LinkedList();
if (o != null) {
newlist.addAll(Arrays.asList((Object[]) o));
}
return newlist;
}
If the first three lines are commented out, ClassCastExceptions result.
Also, I had to do the
addAll dance because Arrays.asList() produces a wierd variety of List
for which remove() is not defined.
>As for the migration guide: How about writing one, now that you're
>through it? This is open source reality as well. :-)
Yup. I've been a contributor to other Apache projects so I know the
drill. I would be willing to write my experiences up, but as seen
above, I don't really understand this package as well as I'd like to, so
you'd have to edit them. If you are willing to have that level of
contribution (and I see no reason why you shouldn't be) then I'd be
happy to contribute one.
-----Original Message-----
From: Jochen Wiedmann [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 05, 2006 12:06 AM
To: [email protected]
Subject: Re: Is there a "distributon" for ws-commons-java5
On 10/5/06, COHEN, STEVEN M (SBCSI) <[EMAIL PROTECTED]> wrote:
> Actually, that is VERY tricky because on this page
>
> http://ws.apache.org/xmlrpc/types.html
>
> It says that an XML-RPC array type maps to an Object[] or
> java.util.List. Very odd. Indeed I found that sometimes it was an
> Object[] and sometimes a List and I had to write a method to handle
> that. Why would it not be consistent, I wonder?
On the server, it simply depends on your choice. If your method
signature contains an Object[], then you receive an Object[]. If your
signature contains a List, then you receive a List. Even better, if
your signature contains a Vector ... then you receive a Vector.
The only place where the logic breaks is the clients return value: The
XML-RPC library doesn't know what type of return value you expect. In
other words, you should always receive an Object[] there.
As for the migration guide: How about writing one, now that you're
through it? This is open source reality as well. :-)
Jochen
--
My wife Mary and I have been married for forty-seven years and not
once have we had an argument serious enough to consider divorce;
murder, yes, but divorce, never.
(Jack Benny)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]