*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 support for collections" Watch "Axis2 support for collections" New topic
Author

Axis2 support for collections

Ram Charan
Greenhorn

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.


thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41128
    
  45
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.


Ping & DNS - my free Android networking tools app
Suryavas.k Kazipeta
Greenhorn

Joined: Nov 24, 2008
Posts: 3
Hi,

Implementing java.util.Collections is possible in WebServices using @XmlJavaTypeAdapter of JAXB 2.0.
have a look on below link and example
https://jaxb.dev.java.net/guide/XML_layout_and_in_memory_data_layout.html

@XmlRootElement
class ComplexStruct {
@XmlJavaTypeAdapter(value=ArrayListDataAdapter.class)
@XmlElement
ArrayList<Data> dataList;
}

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

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

return new ArrayList<Data>(Arrays.asList(objectArray2ArrayList));
}
@Override
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
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
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 ]
 
wood burning stoves
 
subject: Axis2 support for collections
 
Similar Threads
AXIS2 - Databinding question
Axis2 Vs Spring WebServices - SOAP based document/literal WebServices ?
Does the latest version of Eclipse support Axis2 1.5?
CXF supports wsdl 2.0?
Java WebServices with Axis