After working with various complex objects with our Axis web services,
we've discovered several rules when using the built-in BeanSerializer
and BeanDeserializer (above and beyond the JavaBean spec).
These constraints were found while using the Axis Beta1 released on
03/19/2002.
They are derived from our own experiences and are not meant to be part of
the user's
guide. They have not been blessed by the Axis guru's. Hopefully, they will
help developers
avoid some very cryptic errors when using the BeanSerializer and
BeanDeserializer.
Please add to/ correct/ or comment as necessary.
------------
A data object passed on the wire(via AXIS) must adhere to
the JavaBean specification AND some additional constraints. To summarize:
GENERAL
1. All attributes in the class MUST have a public 'get' AND a 'set' method.
You cannot have one without the other. Immutable classes are invalid,
i.e.
'sets' ARE REQUIRED. If you really want to make a bean immutable ,
you'll have to fake-it by making the 'sets' do nothing in their
respectiv
method implementation.
2. All get and set methods MUST have a corresponding attribute.
i.e. if you have a method called 'setMyVariable()', then
'myVariable' must exist as a member in the class. (Also rule #1 applies
so
you need the corresponding 'getMyVariable()'.
3. class must have a public default constructor. (no arguments).
4. Methods starting with 'is' are treated the same as 'get' (per the
JavaBean
spec). Therefore if you have a method 'isXyz()', then you must
have a corresponding 'setXyz()' as well as an xYZ attribute.
INTERFACES
5. If the class implements an interface with any 'get', 'is', or 'set'
methods,
then there MUST be an attribute called 'xYz' in the implemtation class.
ABSTRACT CLASSES
6. If the class extends an abstract class with any attributes, then there
must be getters and setters for those attributes in the implementation.
Also, rule #5 applies to abstract class impl's, too.
Please correct these if necessary.
---------
Allan