SpringBoot接收XML数据

1、请求

@PostMapping(value = "/message", consumes = "application/xml", produces = "application/xml")
public String message(@RequestBody DeviceMessage deviceMessage) throws Exception{
  log.info(deviceMessage.toString());
  return "SUCCESS";
}

2、接收对象

@XmlRootElement(name = "xml")
public class DeviceMessage implements Serializable {

    private static final long serialVersionUID = -1L;

    @XmlElement(name = "ToUserName")
    private String ToUserName;

    @XmlElement(name = "FromUserName")
    private String FromUserName;
    
}

你可能感兴趣的:(SpringBoot接收XML数据)