Assume I have a class “Response” defined as follows:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"field",
"error"
})
@XmlRootElement(name = "Response",namespace="http://www.calculator.com/CalculateNetAmount")
public class Response{
@XmlElement(required = true, namespace="http://www.calculator.com/CalculateNetAmount")
protected String field;
@XmlElement(required = true, namespace="http://www.calculator.com/CalculateNetAmount")
protected String error;
public String getField() { return field; }
public void setField(String value) { this.field = value; }
public String getError() { return error; }
public void setError(String value) { this.error = value; }
}
I’m trying to map this XML:
<cal:Response xmlns:cal="http://www.calculator.com/CalculateNetAmount">
<cal:field>stringField</cal:field>
<cal:error>stringError</cal:error>
</cal:Response>
in the following way:
Response response= XML(xmlInput).mapTo(Response.class);
Notwithstanding the object being created, its parameters strings are empty / null.
What’s wrong in here?