axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <khat...@axiomsystems.com>
Subject RE: Collections classes?
Date Tue, 05 Jul 2005 08:14:23 GMT
Axis uses the JAX-RPC specification for mapping between Java and XSD
types.
You can get the JAX-RPC 1.1 specification from here:
http://java.sun.com/xml/downloads/jaxrpc.html

Lists (and other collection types) are not supported. End of story.
You're barking up the wrong tree to try and force sophisticated
collection objects into SOAP. Really, SOAP is just a way of passing
messages between systems, not objects.
http://weblogs.cs.cornell.edu/AllThingsDistributed/archives/000343.html

Of course, to turn an array into a list is as simple as
java.util.Arrays.asList(Object[]); to turn a list into an array is as
simple as java.util.List.toArray(). JDK 1.5 introduced auto-boxing
between object and primitive types; perhaps you should ask Sun about
introducing auto-boxing between arrays and Lists!

Hope this helps
Keith


-----Original Message-----
From: Scott Lamb [mailto:slamb@slamb.org] 
Sent: 04 July 2005 18:23
To: axis-user@ws.apache.org
Subject: Re: Collections classes?


On 4 Jul 2005, at 08:38, Anne Thomas Manes wrote:
> Actually, a list is a specialization of an array, not the other way 
> around. As James says, a list requires more information than an XSD 
> type array. An XSD type array has no sense of order or index. It is 
> simply a repeating element. There's no metadata included in each of 
> the repeating element to indicate indexing or ordering.

Okay, first of all, when I've been describing arrays, I'm talking  
about arrays on the Java side. I've been treating the SOAP side as a  
black box. I know that Axis is capable of producing a Java array,  
which has the same requirements as a Java List. Thus, I don't need to  
know _anything_ about SOAP or XSD to know that you are wrong. The  
ordering information is there. To give a concrete example, when I do  
a google search with their published WSDL, I get my results in order.  
I simply want that to be a with a List<ResultElement> rather than a  
ResultElement[].

Secondly, of course the XSD does not describe ordering. It doesn't  
need to. When you serialize something as a stream of bytes, you're  
always putting them in order. It's called serialization for a reason.  
The order of the array/list/whatever is the order that the objects  
are written in.

> SOAPpy can easily maps things around because Python is a loosely typed

> language. Java is strongly typed and therefore much more strict about 
> mapping types.

If it can map it to a Java ResultElement[] in advance, why can't it  
map it to a Java List<ResultElement> in advance? Strong typing is not  
the problem.

> In any case, if you want to map the returned array to a Java 
> collection class, then you must write a custom deserializer that does 
> so. You also must define a client config file that tells Axis to use 
> your custom deserializer.

How would I write this custom deserializer? All the information I've  
seen on the website - and the articles James Black linked to - seem  
to be talking about registering new types: i.e., a "java.foo.Blah <->  
Blah". I want to change how XSD x[] to map to Java List<x> rather  
than Java x[], for all x.

Once I do that, I'll look into more sophisticated collections: Maps,  
Sets. I don't know if that's possible, but I'd like to try.

Scott

-- 
Scott Lamb <http://www.slamb.org/>


Mime
View raw message