Need to use SimpleXML and JaxB together



In my scenario, I need to use SimpleXML and JaxB annotations together on an object so that I can use this object to make different kind of REST webservices which we do not want to make any updates.


I have a class below:


@Root(strict=false)


@XmlRootElement


@XmlAcessorType(XmlAccessType.NONE)


public class Patient{



@Element(name ="id", required = false)
@XmlElement(name="id")
private int patno;

@Element(required = false)
private String lastName;

@Element(required = false)
private String firstName;


// not displaying the getters/setters to save space - but no annotations on those methods.


}


I use an object of this class to serialize and send a REST POST request. The REST service's interface method is annotated as below: (this is outside of my area)



@POST
@Produces(MediaType.APPLICATION_XML)
@Consumes(MediaType.APPLICATION_XML)
public StreamingOutput generatePatientData(final Patient patient);


Someone else uses my same patient object to do the simple xmlSerialization for another REST service.


But an exception as below occurs: org.simpleframework.xml.core.PersistenceException: Duplicate annotation of name 'id' on method 'patno'


No comments:

Post a Comment