2016-06-26 8 views
0

私はint-http:outbound-channel-adapterを使用して休憩サービスを呼び出しますが、残念ながら自分のpojoをjsonに変換したくありません。Spring統合: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ヘッダが提供されていない場合、これはJavaオブジェクトのデフォルトのコンテンツタイプです。

使用

<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

素晴らしいです。ありがとうございます。メッセージコンバータはそれ以上必要ではありません。 –

関連する問題