springboot使用jackson xml请求与响应

<dependency>
    <groupId>com.fasterxml.jackson.dataformatgroupId>
    <artifactId>jackson-dataformat-xmlartifactId>
dependency>
@JacksonXmlRootElement(localName = "interface")
public class FpResponse implements Serializable {
	@JacksonXmlProperty(localName = "xmlns:schemaLocation", isAttribute = true)
    private String xmlnsSchemaLocation = "http://www.chinatax.gov.cn/tirip/dataspec/interfaces.xsd";
    @JacksonXmlProperty(localName = "xmlns:xsi", isAttribute = true)
    private String xmlnsXsi = "http://www.w3.org/2001/XMLSchema-instance";
    @JacksonXmlProperty(localName = "version", isAttribute = true)
    private String version = "WLFP1.0";
    private GlobalInfo globalInfo;
    private sajt.shdzfp.bean.Data data;
    private ReturnStateInfo returnStateInfo;
    @JacksonXmlProperty(localName = "globalInfo")
    public GlobalInfo getGlobalInfo() {
        return globalInfo;
    }
    public void setGlobalInfo(GlobalInfo globalInfo) {
        this.globalInfo = globalInfo;
    }
    @JacksonXmlProperty(localName = "data")
    public Data getData() {
        return data;
    }
    public void setData(Data data) {
        this.data = data;
    }
    @JacksonXmlProperty(localName = "returnStateInfo")
    public ReturnStateInfo getReturnStateInfo() {
        return returnStateInfo;
    }
    public void setReturnStateInfo(ReturnStateInfo returnStateInfo) {
        this.returnStateInfo = returnStateInfo;
    }
	@PostMapping(value = "/begin",produces= MediaType.APPLICATION_XML_VALUE, consumes=MediaType.APPLICATION_XML_VALUE)
    public FpResponse begin(@RequestBody Body body) {
    	//body ...
    	return fpResponse;
	}

请求时, 设置Content-type:application/xml

你可能感兴趣的:(Java,spring-boot,java,springboot)