DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17480>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17480

TypeDesc field info not found with Bean without own fields (includes fix)

           Summary: TypeDesc field info not found with Bean without own
                    fields (includes fix)
           Product: Axis
           Version: 1.1RC1
          Platform: All
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


WSDL2Java has generated a bean without own properties. This class extends a 
class with properties.
During the deserialization the BeanDeserializer calls the method:
typeDesc.getFieldNameForElement(elemQName,isEncoded);

Because the corresponding typeDesc has no own fields the method returns with 
null and causes an exception which says that the bean has no appropiate child.

I recommend to do the following changes to enable the TypeDesc to inspect 
superclasses:
In the class: org.apache.axis.description.TypeDesc
1. Change the method as follows:
public String getFieldNameForElement(QName qname, boolean ignoreNS)
    {
        /*
         * BUGFIX
         * Oliver Adler:
         * if this type desc contains no fields we could not return.
         * We have to ask the superclasses !
         */
        /*
         if (fields == null)
            return null;
                */

        // have we already computed the answer to this question?
        if (fieldElementMap != null) {
            String cached = (String) fieldElementMap.get(qname);
            if (cached != null) return cached;
        }

        String result = null;

        String localPart = qname.getLocalPart();

        if(fields != null)
        {
                // check fields in this class
                for (int i = 0; i < fields.length; i++) {
                    FieldDesc field = fields[i];
                    if (field.isElement()) {
                        QName xmlName = field.getXmlName();
                        if (localPart.equals(xmlName.getLocalPart())) {
                            if (ignoreNS || qname.getNamespaceURI().
                                                equals(xmlName.getNamespaceURI
())) {
                                result = field.getFieldName();
                            }
                        }
                    }
                }
        }
        
        // check superclasses if they exist
        if (result == null) {
            Class cls = javaClass.getSuperclass();
            if (cls != null && !cls.getName().startsWith("java.")) {
                TypeDesc superDesc = getTypeDescForClass(cls);
                if (superDesc != null) {
                    result = superDesc.getFieldNameForElement(qname, ignoreNS);
                }
            }
        }

        // cache the answer away for quicker retrieval next time.
        if (result != null) {
            if (fieldElementMap == null) fieldElementMap = new HashMap();
            fieldElementMap.put(qname, result);
        }

        return result;
    }
    
    /**
     * Get the field name associated with this QName, but only if it's
     * marked as an attribute.
     */
    public String getFieldNameForAttribute(QName qname)
    {
        /*
         * BUGFIX
         * Oliver Adler:
         * if this type desc contains no fields we could not return.
         * We have to ask the superclasses !
         */
        /*
         if (fields == null)
            return null;
                */
        String possibleMatch = null;

        if(fields != null)
        {
                for (int i = 0; i < fields.length; i++) {
                    FieldDesc field = fields[i];
                    if (!field.isElement()) {
                        // It's an attribute, so if we have a solid match, 
return
                        // its name.
                        if (qname.equals(field.getXmlName())) {
                            return field.getFieldName();
                        }
                        // Not a solid match, but it's still possible we might 
match
                        // the default (i.e. QName("", fieldName))
                        if (qname.getNamespaceURI().equals("") &&
                            qname.getLocalPart().equals(field.getFieldName())) {
                            possibleMatch = field.getFieldName();
                        }
                    }
                }
        }
        
        if (possibleMatch == null) {
            // check superclasses if they exist
            Class cls = javaClass.getSuperclass();
            if (cls != null && !cls.getName().startsWith("java.")) {
                TypeDesc superDesc = getTypeDescForClass(cls);
                if (superDesc != null) {
                    possibleMatch = superDesc.getFieldNameForAttribute(qname);
                }
            }
        }
        
        return possibleMatch;
    }

Reply via email to