File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Axis2 support for collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 support for collections" Watch "Axis2 support for collections" New topic

Axis2 support for collections

Ram Charan

Joined: Apr 07, 2004
Posts: 12
Does axis2 support collections as return types and input arguments in webservices? My deployment env is Axis2 + JBoss4.2 + EJB3.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
You should not use Java collections in a web service. They're not part of XML Schema, and thus can't be used by WSDL. They're also not cross-platform compatible, which is a major point of WS. Use arrays instead of collections.
Suryavas.k Kazipeta

Joined: Nov 24, 2008
Posts: 3

Implementing java.util.Collections is possible in WebServices using @XmlJavaTypeAdapter of JAXB 2.0.
have a look on below link and example

class ComplexStruct {
ArrayList<Data> dataList;

class ArrayListDataAdapter extends XmlAdapter<Data[], ArrayList<Data>> {

public ArrayList<Data> unmarshal(Data[] objectArray2ArrayList) {
if ( objectArray2ArrayList == null )
return null;

return new ArrayList<Data>(Arrays.asList(objectArray2ArrayList));
public Data[] marshal(ArrayList<Data> arrayList2ObjectArray) {
if ( arrayList2ObjectArray == null )
return null;

Data[] dataArray = new Data[ arrayList2ObjectArray.size() ];
int i=0;
for (Data data : arrayList2ObjectArray) {
dataArray [ i++ ] = data;
return dataArray;
Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
Originally posted by Suryavas.k Kazipeta:

Consider using instead:

In general:

See also Implementing Collections In WebServices
[ November 25, 2008: Message edited by: Peer Reynders ]
I agree. Here's the link:
subject: Axis2 support for collections
It's not a secret anymore!