I am trying to use byte array like this (JAXB class). However, I am getting all 0s in the msg field even though I pass valid characters. The "id" and "myid" fields are parsed successfully and it is failing for the byte array field.
@XmlRootElement(name = "testMessage") @XmlAccessorType(XmlAccessType.FIELD) public class TestMessage { @XmlAttribute private Integer id; @XmlElement(name = "myid") private Long myid; @XmlElement(name = "msg") private byte[] msg; }
Best Answer
Using JAXB of Java 1.6.0_23 i get the following xml file for a TestMessage instance:
If you unmarshall this xml content you should get back the TestMessage instance including the msg byte array (which is base64 encoded in the xml file).