Jaxb - Ignore unknown Attributes



I have a parent class which contains an enum "ActionType".



@XmlRootElement(name="Action")
public class ActionDto {
[...] ActionType type;
}


and some child-classes which extends ActionDto and have more special attributes like password (the LoginDto).


It's a server-client-connection. I want to send some data from my client to my server. So I serialize it (I use Jaxb) and deserialize it to an ActionDto-object.


An example for a LoginDto-Object:



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Action>
<type>LOGIN</type>
<password>Testpassword</password>
</Action>


I get an error if I want to deserialize it to an ActionDto-object - I think it's caused by the password-attribute. Can I make the Jaxb-unmarshaller ignore those unknown attributes?


Is there an other possibility to unmarshal it directly to my LoginDto-Object (The server receives just a xml-String, I don't know the special type) ?


No comments:

Post a Comment