I am trying to deserialize received Entity from JAX-RS web service, however can't manage to do it succesfully for reference fields. The format of xml passed is :
<?xml version="1.0" encoding="UTF-8"?>
<linkReaderImpl>
<name>DPIa0Nffg0WEBCLIENTt0Nffg0</name>
<source>DPIa0Nffg0</source>
<destination>WEBCLIENTt0Nffg0</destination>
<latency>0</latency>
<throughput>0.0</throughput>
</linkReaderImpl>
and the LinkReaderImpl class looks like:
@XmlRootElement
@XmlAccessorType( XmlAccessType.FIELD)
public class LinkReaderImpl extends NamedEntityReaderImpl implements LinkReader, Serializable{
@XmlElement @XmlIDREF
private NodeReaderImpl source;
@XmlElement @XmlIDREF
private NodeReaderImpl destination;
private int latency;
private float throughput;
public void setLatency(int latency) {
this.latency = latency;
}
public void setThroughput(float throughput) {
this.throughput = throughput;
}
public LinkReaderImpl() {
super(null);
this.source = null;
this.destination = null;
this.latency = 0;
this.throughput = 0;
}
@Override
public NodeReader getSourceNode() {
return this.source;
}
public void setSource(NodeReaderImpl source) {
this.source = source;
}
@Override
public NodeReader getDestinationNode() {
return this.destination;
}
public void setDestination(NodeReaderImpl destination) {
this.destination = destination;
}
@Override
public int getLatency() {
return this.latency;
}
@Override
public float getThroughput() {
return this.throughput;
}
}
When done with :
LinkReaderImpl returnReader = response.readEntity(LinkReaderImpl.class);
Elements like name, latency, throughput get successfully deserialized. However, source and destination always end up being null despite obviously being marshalled and unmarshalled as intended. Is it some simple problem or I completely misunderstood id/idref functionality?