Xml RestTemplate为指定对象返回空字段
我有下面的Xml RestTemplate为指定对象返回空字段,xml,spring-boot,resttemplate,Xml,Spring Boot,Resttemplate,我有下面的try块,我希望restemplate的exchange方法会有响应: try{ response = restOperations.exchange("http://localhost:8080/midpoint/ws/rest/users/00000000-0000-0000-0000-000000000002", HttpMethod.GET, new HttpEntity<String>
try
块,我希望restemplate
的exchange
方法会有响应:
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());
}
服务器响应的一个示例:
<?xml version="1.0" encoding="UTF-8"?>
<user xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" oid="00000000-0000-0000-0000-000000000002" version="194">
<name>administrator</name>
<metadata>
<requestTimestamp>2017-01-31T14:04:14.575+01:00</requestTimestamp>
<createTimestamp>2017-01-31T14:04:14.658+01:00</createTimestamp>
<createChannel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#init</createChannel>
</metadata>
<assignment id="1">
<metadata>
<requestTimestamp>2017-01-31T14:04:14.575+01:00</requestTimestamp>
<createTimestamp>2017-01-31T14:04:14.658+01:00</createTimestamp>
<createChannel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#init</createChannel>
</metadata>
<targetRef oid="00000000-0000-0000-0000-000000000004" type="c:RoleType" />
<activation>
<effectiveStatus>enabled</effectiveStatus>
</activation>
</assignment>
<activation>
<administrativeStatus>enabled</administrativeStatus>
<effectiveStatus>enabled</effectiveStatus>
<enableTimestamp>2017-01-31T14:04:14.598+01:00</enableTimestamp>
<lockoutStatus>normal</lockoutStatus>
</activation>
<iteration>0</iteration>
<iterationToken />
<roleMembershipRef oid="00000000-0000-0000-0000-000000000004" type="c:RoleType" />
<fullName>midPoint Administrator</fullName>
<givenName>midPoint</givenName>
<familyName>Administrator</familyName>
<credentials>
<password>
<lastSuccessfulLogin>
<timestamp>2017-02-16T17:01:21.861+01:00</timestamp>
</lastSuccessfulLogin>
<previousSuccessfulLogin>
<timestamp>2017-02-16T16:44:00.493+01:00</timestamp>
</previousSuccessfulLogin>
<metadata>
<createTimestamp>2017-01-31T14:04:14.598+01:00</createTimestamp>
<createChannel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#init</createChannel>
</metadata>
<value>
<t:encryptedData>
<t:encryptionMethod>
<t:algorithm>http://www.w3.org/2001/04/xmlenc#aes128-cbc</t:algorithm>
</t:encryptionMethod>
<t:keyInfo>
<t:keyName>HZZUFItbX7fYQO41GT3PHJtIf2Q=</t:keyName>
</t:keyInfo>
<t:cipherData>
<t:cipherValue>SZusPiIgcrzoqDfm9uTzmrI6r4lG/OolTRIc7V/0aVo=</t:cipherValue>
</t:cipherData>
</t:encryptedData>
</value>
</password>
</credentials>
</user>
管理员
2017-01-31T14:04:14.575+01:00
2017-01-31T14:04:14.658+01:00
http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#init
2017-01-31T14:04:14.575+01:00
2017-01-31T14:04:14.658+01:00
http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#init
启用
启用
启用
2017-01-31T14:04:14.598+01:00
正常的
0
中点管理员
中点
管理员
2017-02-16T17:01:21.861+01:00
2017-02-16T16:44:00.493+01:00
2017-01-31T14:04:14.598+01:00
http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#init
http://www.w3.org/2001/04/xmlenc#aes128-cbc
HZZUFITBX7FYQO41GT3PJTIF2Q=
SZusPiIgcrzoqDfm9uTzmrI6r4lG/OolTRIc7V/0aVo=
我解决了在我的pom.xml
文件中添加jackson
依赖项的问题:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
com.fasterxml.jackson.dataformat
jackson数据格式xml
我解决了在我的pom.xml
文件中添加jackson
依赖项的问题:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
com.fasterxml.jackson.dataformat
jackson数据格式xml
你能分享一个示例性回答吗?我用一个回答更新了我的问题示例你能分享一个示例性回答吗?我用一个回答更新了我的问题示例我有同样的问题,但你的解决方案不起作用。我理解我的问题。restemplate.exchange方法不适用于我的实际java版本1.8.0.151,我返回到1.8.0.72它工作正常。最近的java版本发生了什么?我也遇到了同样的问题,但您的解决方案不起作用。我理解我的问题。restemplate.exchange方法不适用于我的实际java版本1.8.0.151,我返回到1.8.0.72它工作正常。最近的java版本发生了什么?