Hi,
I have a class defined as:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement( name = "" )
@XmlType(name = "ReportRunResult", propOrder = {
"runInformation",
})
public class ReportRunResult implements Serializable
{
@XmlElement(name = "RunInformation", required = true)
protected ReportRunInformationType runInformation;
...
I return it from a JAX-RS method as such:
@Override
@Path( "/run" )
@Consumes({ "application/json", "application/xml" })
@POST
public ReportRunResult runReport( RunReportOptions
runReportOptions ) {
...
try {
...
ReportRunResult result = new ReportRunResult();
result.setRunInformation(response.getRunInformation());
return result;
But I can't deserialise it like this:
Response response = client.post( runOpts );
assertEquals(200, response.getStatus() );
ReportRunResult runResult = response.readEntity(
ReportRunResult.class );
This produces an error of:
javax.xml.bind.UnmarshalException: unexpected element (uri:"",
local:"RunInformation"). Expected elements are <{}>
If I read the entity as a string it gives me:
{"RunInformation":{"RunHeader":{"Project":"Ringo",...
Looking here:
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-DealingwithJSONarrayserializationissues
(the only place I can find an example of the JSON that is expected from
CXF) shows that the top level object is contained with a wrapper JSON
object:
{"post":{"title":"post","comments":[{"title":"comment1"},{"title":"comment2"}]}}
But that isn't what happened in my case (no wrapper JSON object).
What do I need to change to get this to work correctly?
Thanks
Jim