RestTemplate返回指定对象的空字段

时间:2017-02-16 14:12:31

标签: xml spring-boot resttemplate

我有以下try块,我期待来自exchange的{​​{1}}方法的回复:

RestTemplate

我期待类型try{ response = restOperations.exchange("http://localhost:8080/midpoint/ws/rest/users/00000000-0000-0000-0000-000000000002", HttpMethod.GET, new HttpEntity<String>(createHeaders("administrator", "5ecr3t")), UserType.class); logger.info(response.getBody()); } 的响应,请求正确执行,状态为200 OK,但UserType模型的所有字段都为空,因此我从REST调用未被绑定(映射)。 UserType的必填字段标注为:

UserType

服务器响应的一个示例:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserType", propOrder = {
    "fullName",
    "givenName",
    "familyName",
    "additionalNames",
    "locality",
    "assignment",
    "activation",
    "specialWithInternalizedName",
    "singleActivation", 
    "multiActivation",
    "multiActivationCopy",
    "singleConstruction",
    "multiConstruction",
    "multiConstructionCopy"
})

1 个答案:

答案 0 :(得分:0)

我解决了在jackson文件中添加pom.xml依赖项的问题:

        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </dependency>