I\'ve written some webservices where some return a simple String (this ones work) and other returning a list of objects. No, axis2 (1.5.1) cannot handle collection types, so I c
Actually, the return type of the Method of Web service should be non-generic.
it should not be Object , or just a List...
so , return a specific Person class object ..if one object of Person class need to return or if list of object is there.....use... list.....
do change....and enjoy....!!!!!
Axis cannot find the mapping that it needs to be able to translate the objects that you are sending via the XML. It doesn't know how to translate the XML into an object, or the other way around. A good idea is to return an object which contains an array of objects.
With Axis, you must tell it how to do the mapping between the XML and an object. This is defined using the WSDL and the Classes themselves.
1) Look at the WSDL generated by the web service: You can find this by looking at http://localhost:8080/Service?wsdl. Check this is OK.
2) Axis find it's mapping by looking at the return value of Class.getTypeDesc(); Check that this mapping is correct.
For one of my services, I have the following mapping defined as the return value of a web service (class RechercherBatimentRetour, a sub-class of Retour).
typeDesc.setXmlType(new QName("sbatimentto", "RechercherBatimentRetour")); // 1
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("batiments");
elemField.setXmlName(new QName("", "batiments")); // 2
elemField.setXmlType(new QName("sbatimentto", "ResumeBatimentTo"));
elemField.setNillable(true);
typeDesc.addFieldDesc(elemField);
This is defining the return value of this SOAP service.
// 1 -> This is saying that the WSDL ComplexType RechercherBatimentRetour is in the namespace 'sbatimentto'.
// 2 -> We're adding the field 'batiments' to the ComplexType, which is defined via a getter and setter in the class as:
public ResumeBatimentTo[] getBatiments() {
return batiments;
}
public void setBatiments(ResumeBatimentTo[] batiments) {
this.batiments = batiments;
}
The ResumeBatimentTo is also in the same namespace. So this ends up with a WSDL which contains (amoungst other things)
<complexType name="Retour"> <sequence> <element name="codeRetour" nillable="true" type="xsd:string"/> <element name="message" nillable="true" type="xsd:string"/> <element name="statut" type="xsd:boolean"/> </sequence> </complexType> <complexType name="RechercherBatimentRetour"> <complexContent> <extension base="tns1:Retour"> <sequence> <element name="batiments" nillable="true" type="impl:ArrayOf_tns1_ResumeBatimentTo"/> </sequence> </extension> </complexContent> </complexType>
All used classes must have a getTypeDesc, getSerializer & getDeserializer defined correctly in order to be able to be used.