Wrong order of inherinted attributes in Axis2

Posted on January 21, 2008


I found a bug in Axis2 which prevents .NET client accessing inherited attributes defined in super class. This is due to the sequence of elements in generated response is not correct. Basically based on the WSDL generated by Axis2, attributes from super class should be appended first and sorted, then attributes from subclass. Clearly, Axis2 appends attributes in a wrong order, it tries to add attributes from subclass first. The BeanUtil class is responsible to generate SOAP response for ADB and POJO styled web service, therefore I made a modification to this class as follows.

// properties from JAM
ArrayList propertyList = new ArrayList();
JProperty properties[] = jClass.getDeclaredProperties();
for (int i = 0; i < properties.length; i++) {
  JProperty property = properties[i];
JClass supClass = jClass.getSuperclass();
while (!"java.lang.Object".equals(supClass.getQualifiedName())) {
  ArrayList list = new ArrayList();
  properties = supClass.getDeclaredProperties();
  for (int i = 0; i < properties.length; i++) {
    JProperty property = properties[i];
    // Changed by MSU to make sure inheritance works!
    // propertyList.add(property);
  } Collections.sort(list);
  // Added by MSU
  for (int i = 0; i < propertyList.size(); i++) {
  propertyList = list;
  supClass = supClass.getSuperclass();
Posted in: Development