Within the Spring framework, I am looking use RestTemplate
(yes I know rest template isn't ideal but the infrastructure is already in place) to POST a DTO DtoRequest
with parameters field1
, field2
, and field3
. When the request body is marshalled, it looks like:
<DtoRequest>
<field1>field 1 value</field1>
<field2>field 2 value</field2>
<field3>field 3 value</field3>
</DtoRequest>
However, the api I'm hitting actually needs a request body without the <DtoRequest>
tag so that it looks like:
<field1>field 1 value</field1>
<field2>field 2 value</field2>
<field3>42</field3>
This is proving harder for me than I feel like it should be; I thought there would be an annotation I could use to make this happen, but I'm not finding a convenient one. I'd prefer not to set a custom marshaller if I don't have to. Right now the dto class looks like
@JacksonXmlRootElement
public class DtoRequest {
@JacksonXmlProperty
private String field1
@JacksonXmlProperty
private String field2
@JacksonXmlProperty
private Integer field3
//Getters and setters
}
Any help is greatly appreciated!