2016-06-26 3 views
0

int-http:outbound-channel-adapter 내 휴식 서비스를 호출하고 싶지만, 불행히도 내 pojo를 json으로 변환하고 싶지 않습니다.스프링 통합 : int-http : 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 

답변

1

[application/x-java-serialized-object]

contentType 헤더가 제공되지 않는 경우가 자바 객체에 대한 기본 콘텐츠 유형입니다.

사용

<int:header-enricher input-channel="ticketOutgoingPreProcessChannel" 
     output-channel="ticketOutgoingChannel"> 
    <int:header name="contentType" value="application/json" overwrite="true/> 
</int:header-enricher> 

는 JSON으로 변환하는 어댑터를 지시합니다.

+0

답장을 보내 주셔서 감사합니다. 나는 응답을 기대하지 않기 때문에''를 선택했다. ' '를 어떻게 사용해야하는지 조금 설명해 주시겠습니까? 작은 예제가 좋을 수도 있습니다. pojo를 통합 컨텍스트에 보내는 것은' '를 사용합니다. 그래서 헤더가 x-java-serialized-object로 설정되어 있다고 생각합니다. –

+0

내 실수 - 아무것도 제공되지 않는 경우 기본 'contentType'입니다. 내 편집을 참조하십시오. ''나는 응답을 기대하지 않는다'- 그 경우에, 당신은''예상 응답 유형''을 필요로하지 않는다. 그것이 나를 던진 것이다. –

+0

신난다. 고마워 .Btw. 메시지 변환기는 더 이상 필요하지 않습니다. –

관련 문제