SpringBoot接收XML数据

2021-05-16  本文已影响0人  刘二先生说

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;
    
}
上一篇下一篇

猜你喜欢

热点阅读