I think if you add an @XmlSeeAlso annotation to the "base" bean that points to 
all the subclasses, it should work.  That should allow JAXB to find the 
subclasses it needs.   

Dan


On Tuesday 30 March 2010 8:53:24 pm Betts, Chuck wrote:
> In the application I am developing, we decided we wanted to add
> validation logic to the classes generated by JAXB when using WSDL to
> Java data binding.  However, we decided to keep the validation logic in
> a sub-class of the JAXB generated object.  So for example, this is the
> JAXB generated class:
> 
> 
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> 
> @XmlType(name = "Email", propOrder = {
> 
>     "value"
> 
> })
> 
> public class EmailBase {
> 
> 
> 
>     @XmlValue
> 
>     protected String value;
> 
> 
> 
>     //Removed getters and setters
> 
> }
> 
> 
> 
> And this is the subclass:
> 
> 
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> 
> @XmlType(name = "Email", propOrder = {
> 
>     "value"
> 
> })
> 
> public class Email extends EmailBase implements DataObjectBase
> 
> {
> 
> 
> 
>     public boolean validate()
> 
>     {
> 
>       //validation logic
> 
>     }
> 
> 
> 
> }
> 
> 
> 
> Now, when our Web Service receives a Request message with the Email
> parameter, we'd like CXF/JAXB to unmarshall the parameter to a subclass
> object, rather than the base class.  Is there a way to configure CXF or
> JAXB to do so?

-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog

Reply via email to