我想使用int-http:outbound-channel-adapter
调用我的休息服务,但不幸的是它不想将我的pojo转换为json。
我的配置:
<int-http:outbound-channel-adapter
channel="ticketOutgoingChannel"
http-method="PUT"
url="http://localhost:8080/process/ticket"
expected-response-type="*.model.Ticket"
message-converters="converters"
/>
<util:list id="converters">
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.StringHttpMessageConverter" />
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</util:list>
堆栈跟踪:
Caused by: org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [*.model.Ticket] and content type [application/x-java-serialized-object]
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:810)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:594)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:493)
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:382)
... 34 more
答案 0 :(得分:1)
[application/x-java-serialized-object]
如果未提供contentType
标头,则这是Java对象的默认内容类型。
使用
<int:header-enricher input-channel="ticketOutgoingPreProcessChannel"
output-channel="ticketOutgoingChannel">
<int:header name="contentType" value="application/json" overwrite="true/>
</int:header-enricher>
指示适配器转换为JSON。