I already have the implementation to post the xml data to my controller but I am having some issues with the data I am trying to read due the XML format I given work with.
My Controller:
@RequestMapping(method = RequestMethod.POST, consumes = {MediaType.APPLICATION_XML_VALUE}, produces = {MediaType.APPLICATION_XML_VALUE} )
public ResponseEntity<?> SlaDetails(@RequestBody AgentSla[] task_sla) {
MessageDto messageDto = new MessageDto();
for (AgentSla next: task_sla){
System.out.println(next.getStage());
}
messageDto.setMsg("ok");
return ResponseEntity.status(HttpStatus.CREATED).body(messageDto);
}
My Entity:
@XmlRootElement(name="task_sla")
public class AgentSla {
private Long id;
private String stage;
private String timezone;
//getters and setters
XML doc sample:
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<task_sla>
<stage>boo</stage>
<timezone display_value="IN">12345</timezone>
</task_sla>
<task_sla>
<stage>foo</stage>
<timezone display_value="SR">12345</timezone>
</task_sla>
</xml>
The Issue: I can read any value of the XML "subchilds" i.e "<stage>boo</stage>
" or </timezone>
the problem I have is on the "<timezone display_value="IN">12345</timezone>
". On this child it reads only the value "12345" but I also need the "display_value="SR" " value.
Is it possible to read that value or...should I just give up.