I'm still not terribly sure about the internal workings of Axis, but I think
the bean deserializer was finding the field, but not finding the property
description for that field, hence the exception I was seeing.

The problem wasn't with finding the field name, but with finding the
property descriptor for that field.

For example, the field IsEnabled has the following field description:

  org.apache.axis.description.FieldDesc field = new
org.apache.axis.description.ElementDesc();
  field.setFieldName("IsEnabled");
  field.setXmlName(new
javax.xml.namespace.QName("urn:semi-org:schema:eda_ps_v0.0", "IsEnabled"));
  field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema";, "boolean"));
  typeDesc.addFieldDesc(field);

I tried changing the field name to "isEnabled", but get the "invalid element
... - IsEnabled" exception on the return value.

Somehow Axis is doing a mapping from XmlName -> FieldName which is
independant of the defined fieldName setup in the type descriptor.

In the code for BeanDeserializer:

        if (typeDesc != null) {
            // Lookup the name appropriately (assuming an unqualified
            // name for SOAP encoding, using the namespace otherwise)
            String fieldName = typeDesc.getFieldNameForElement(elemQName,
                                                               isEncoded);
            propDesc = (BeanPropertyDescriptor)propertyMap.get(fieldName);
            fieldDesc = typeDesc.getFieldByName(fieldName);
        }

        if (propDesc == null) {
            // look for a field by this name.
            propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
        }

You can see that if the java.beans.Introspector is converting the field name
into a "beans compatible" format, then the lookup of the property
description will fail, and thus the call will fail.

The only way around this I found was to override the BeanInfo interface and
return the properties with an uppercase first letter.

if there is another way around this behavrion, I'm all ears - implementing
BeanInfo looks and feels like a kludge.

-----Original Message-----
From: Tom Jordahl [mailto:tomj@;macromedia.com]
Sent: Monday, November 11, 2002 4:17 PM
To: '[EMAIL PROTECTED]'
Subject: RE: problem solved for de-serializer, bean question



JAX-RPC specifies XML -> Java name translation, which Axis implements.
JavaBean properties have a lower-case first letter.

Axis should include the XML name in the Meta-data in the Bean, so
that on the wire, the XML element has the name specified in the WSDL.

Hope this helps.
--
Tom Jordahl


-----Original Message-----
From: dweber [mailto:dweber@;asyst-connect.com]
Sent: Monday, November 11, 2002 2:38 AM
To: [EMAIL PROTECTED]
Subject: problem solved for de-serializer, bean question


I've finally solved my client connection problems with axis, and the problem
ended up being an issue with the naming of the bean property.  Essentially,
I had a message:

<IsEdaEnabledResponse>
  <IsEnabled>false</IsEnabled>
</IsEdaEnabledResponse>

and a class to handle this response (I'm simplifying the message structure).
I finally figured out that the wsdlToJava tool was not (for me) correctly
implementing the stubs (which is another story).  I hand-finagled the stub
to add the response message, but kept getting the error about an invalid
element - IsEnabled.  I verified that the field was present in the response
stubs TypeDescr field, but no joy.  I finally downloaded the source and
spent the weekend digging through the serialization logic, and finally found
the section in BeanUtils where the property descriptors were acquired using
Introspector.getBeanInfo().getPropertyDescriptors().

When I printed out the fields returned by this method (using getName() on
each property), I found that the bean field was named "isEnabled", while the
tag was named "IsEnabled" - note the case issue.  Once I modified the server
to return the tag as "isEnabled" the code worked fine.

The bizarre thing, and what prompts my question, is that the response class
*does not have a field named "isEnabled"*, it's named "IsEnabled". [private
boolean IsEnabled;] The accessors are named "getIsEnabled" and
"setIsEnabled", there isn't a lowercase "isEnabled" anywhere to be found.

For my server, this won't be an issue, since I control the tags.  It's quite
possible this will be an issue when I connect to the real server, which has
the uppercase first letter in the tag.

Can someone explain where this field comes from, and if it's possible to set
it somehow?


Reply via email to