I use Spring and Apache CXF for my project that implements java Web Services with first-code style.
I have a variable as defined:
@XmlTransient
public String word;
So that variable doesn't map to an attribute at XML.
However I want it to be ignored to mapping XML element at serialization but not at deserialization.
How can I do that?
I don't think you can achieve that with @XmlTransient. An option would be to use MOXy to marshal using one schema and unmarshal using another schema. You can find a great example here.
A simple but less elegant workaround would be something like this:
@XmlTransient
public String word;
public void setDeserializedWord(String word) {
this.word = word;
}
@XmlElement(name="word")
public String getDeserializedWord() {
return null;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With