title: Could not extract response: no suitable HttpMessageConverter found for response type
body: <p>I am new with spring integration and working in spring integration http module for my project requirement.  I am sending request from outbound gateway  as a http client.
  I am trying to initiate a request  to the server  and server should return  me  the message payload with my set values.  I am converting object to JSON  using to send to server 
  I am sending a request to inbound gateway present on the server side from client(HttpClientDemo) shown below. For that purpose, I am converting my object into the JSON and then converting to JSON string to object on the client side, performing some simple operation there and sending it back to the client(HttpClientDemo) but before this, I am getting exception related to HttpMessageConverter as below:</p>
  
  <pre><code>Exception in thread "main" org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.mycompany.MyChannel.model.FFSampleResponseHttp] and content type [text/plain;charset=UTF-8]
      at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:108)
      at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:784)
      at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:769)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:549)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:517)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:462)
      at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:421)
      at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)
      at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
      at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
      at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
      at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
      at org.springframework.integration.channel.AbstractSubscribablMyChannel.doSend(AbstractSubscribablMyChannel.java:77)
      at org.springframework.integration.channel.AbstractMessagMyChannel.send(AbstractMessagMyChannel.java:255)
      at org.springframework.integration.channel.AbstractMessagMyChannel.send(AbstractMessagMyChannel.java:223)
      at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:114)
      at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:44)
      at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:93)
  </code></pre>
  
  <p>Please find  Below related code :</p>
  
  <p>Client side code:
  HttpClientDemo.java</p>
  
  <pre><code>public class HttpClientDemo {
  
      private static Logger logger = Logger.getLogger(HttpClientDemo.class);
      public static void main(String[] args) {
          ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/http-outbound-config.xml");
  RequestGateway requestGateway = context.getBean("requestGateway", RequestGateway.class);        
          FFSampleRequestHttp FFSampleRequesthttp = new FFSampleRequestHttp();
          FFSampleRequesthttp.setMyChannelID("1");
          FFSampleRequesthttp.setMyNumber("88");
          FFSampleRequesthttp.setReferenceID("9I");
          FFSampleRequesthttp.setTemplateType(1);
          FFSampleRequesthttp.setTimestamp("today");
          FFSampleResponseHttp  reply = requestGateway.FFSampleResponsegatway(FFSampleRequesthttp);
              logger.info("Replied with: " + reply);
      }
  
  }
  </code></pre>
  
  <p>My Request Gateway is as follows: RequestGateway.java</p>
  
  <pre><code>public interface RequestGateway {
  
  
      FFSampleResponseHttp FFSampleResponsegatway(FFSampleRequestHttp request);
  
  }
  </code></pre>
  
  <p>http-outbound-config.xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:int="http://www.springframework.org/schema/integration"
      xmlns:int-http="http://www.springframework.org/schema/integration/http"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
          http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd"&gt;
  
      &lt;int:gateway id="requestGateway" 
                   service-interface="com.mycompany.MyChannel.Common.RequestGateway"
                   default-request-channel="requestChannel"/&gt;
  
      &lt;int:channel id="requestChannel"/&gt;
      &lt;int:channel id="requestChannel1"/&gt;
  
  
  &lt;!--    com.mycompany.MyChannel.model.FFSampleResponseHttp --&gt;
  
      &lt;int-http:outbound-gateway request-channel="requestChannel1" reply-channel="replyChannel1" url="http://localhost:8080/MyChannel_prj-1.0.0.BUILD-SNAPSHOT/receiveGateway"  http-method="POST"  extract-request-payload="true" expected-response-type="com.mycompany.MyChannel.model.FFSampleResponseHttp"/&gt;
  
     &lt;int:object-to-json-transformer  input-channel="requestChannel" output-channel="requestChannel1" content-type="application/json"  result-type="STRING"/&gt;
  
  
  
     &lt;bean id="FFSampleRequestHttp" class="com.mycompany.MyChannel.model.FFSampleRequestHttp"&gt;&lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="no"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;MyChannel-http&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
        &lt;param-value&gt;/WEB-INF/servlet-config.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyChannel-http&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/receiveGateway&lt;/url-pattern&gt;
     &lt;/servlet-mapping&gt;
  
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>servlet-config.xml</p>
  
  <pre><code>    &lt;int:channel id="receivMyChannel"/&gt;
  
  &lt;int-http:inbound-gateway request-channel="receivMyChannel" path="/receiveGateway" supported-methods="POST"/&gt;
  
      &lt;int:service-activator input-channel="receivMyChannel"&gt;
          &lt;bean class="com.mycompany.MyChannel.serviceImpl.FFSampleHttpImpl"&gt;
          &lt;constructor-arg ref = "FFSampleRequestHttp"&gt;&lt;/constructor-arg&gt;
          &lt;/bean&gt;
          &lt;/int:service-activator&gt;
  
  
       &lt;bean id="FFSampleRequestHttp" class="com.mycompany.MyChannel.model.FFSampleRequestHttp"&gt;&lt;/bean&gt;
       &lt;bean id="FFSampleResponseHttp" class="com.mycompany.MyChannel.model.FFSampleResponseHttp"&gt;&lt;/bean&gt;
  
      &lt;/beans&gt; 
  
  
  
  public class FFSampleHttpImpl{
  
      private static org.apache.log4j.Logger log = Logger
              .getLogger(FFSampleImpl.class);
  
      @Autowired
      FFSampleRequestHttp request;
      public FFSampleHttpImpl() {
      }
  
      public FFSampleHttpImpl(FFSampleRequestHttp request) {
          super();
          this.request = request;
      }
  
  
  
  
  
      public String issueResponseFor(String str) throws JsonParseException, JsonMappingException, IOException {
  
          ObjectMapper mapper = new ObjectMapper();
  
          FFSampleRequestHttp FFSampleRequestHttp = mapper.readValue(new String(str), FFSampleRequestHttp.class);
  
          FFSampleRequestHttp.setReferenceID("Hi My Number");
  
          String  strs = new String();
  
          strs = mapper.writeValueAsString(FFSampleRequestHttp);
  
              return strs;
  
          }
  
  }
  </code></pre>
  
  <p>FFSampleRequestHttp.java</p>
  
  <pre><code>public class FFSampleRequestHttp {
      protected String MyNumber;  
      protected String referenceID;   
      protected String myChannelID;
      protected String timestamp;
      protected int templateType;
      public String getMyNumber() {
          return MyNumber;
      }
      public void setMyNumber(String MyNumber) {
          this.MyNumber = MyNumber;
      }
      public String getReferenceID() {
          return referenceID;
      }
      public void setReferenceID(String referenceID) {
          this.referenceID = referenceID;
      }
      public String getMyChannelID() {
          return myChannelID;
      }
      public void setMyChannelID(String myChannelID) {
          this.myChannelID = myChannelID;
      }
      public String getTimestamp() {
          return timestamp;
      }
      public void setTimestamp(String timestamp) {
          this.timestamp = timestamp;
      }
      public int getTemplateType() {
          return templateType;
      }
      public void setTemplateType(int templateType) {
          this.templateType = templateType;
      }
      }
  </code></pre>
  
  <p>FFSampleResponseHttp.java</p>
  
  <pre><code>public class FFSampleResponseHttp {
      protected String MyNumber;
      protected String referenceID;
      protected String myChannelID;
      protected String timestamp;
      protected int templateType;
  
      public String getMyNumber() {
          return MyNumber;
      }
      public void setMyNumber(String MyNumber) {
          this.MyNumber = MyNumber;
      }
      public String getReferenceID() {
          return referenceID;
      }
      public void setReferenceID(String referenceID) {
          this.referenceID = referenceID;
      }
      public String getMyChannelID() {
          return myChannelID;
      }
      public void setMyChannelID(String myChannelID) {
          this.myChannelID = myChannelID;
      }
      public String getTimestamp() {
          return timestamp;
      }
      public void setTimestamp(String timestamp) {
          this.timestamp = timestamp;
      }
      public int getTemplateType() {
          return templateType;
      }
      public void setTemplateType(int templateType) {
          this.templateType = templateType;
      }
      }
  </code></pre>
  
  <p>When I run the above code I get following error: </p>
  
  <pre><code>16:55:46.843 [main] DEBUG o.s.web.client.RestTemplate - Writing [{"MyNumber":"88","referenceID":"9I","myChannelID":"1","timestamp":"today","templateType":1}] as "text/plain;charset=UTF-8" using [org.springframework.http.converter.StringHttpMessageConverter@7d31a3e2]
  16:55:46.988 [main] DEBUG o.s.web.client.RestTemplate - POST request for "http://localhost:8080/MyChannel_prj-1.0.0.BUILD-SNAPSHOT/receiveGateway" resulted in 200 (OK)
  Exception in thread "main" org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.mycompany.MyChannel.model.FFSampleResponseHttp] and content type [text/plain;charset=UTF-8]
      at org.springframework.web.client.HttpMessageConverterExtractor. 
  </code></pre>
  
  <p>I have used spring integration  basic sample code for reference.
  Please provide your input. I also tried by using the spring object mapper in the configuration files with JSON to object transformer but then also I am getting similer issues for HttpMessageConverter.
  Please help me with your valuable inputs/suggestion and let me know if we have any limitation with spring integration http object mapper.</p>
  
  <hr>
  
  <p>Hi Artem,
  Thanks for your reply. I am still facing some challenges mentioned below. I have done the changes in my configuration files as per of your suggestion. but facing issue when using Jackson2JsonObjectMapper and need your further help. Please find below issue description.</p>
  
  <p>I have done changes in my files and now files are like below:
  My Servlet-Config.xml file content is as below:</p>
  
  <pre><code>&lt;int:channel id="channel1" /&gt; 
  &lt;int:channel id="channel2" /&gt; 
  &lt;int:channel id="channel3" /&gt; 
  &lt;int-http:inbound-gateway request-channel="channel1" supported-methods="POST" path="/receiveGateway" /&gt; 
  - &lt;int:service-activator input-channel="channel2"&gt; 
  - &lt;bean class="com.myCompany.myChannel.serviceImpl.FFSampleHttpImpl"&gt; 
  &lt;constructor-arg ref="ffSampleRequestHttp" /&gt; 
  &lt;/bean&gt; 
  &lt;/int:service-activator&gt; 
  
  &lt;int:json-to-object-transformer input-channel="channel1" output-channel="channel2" type="com.myCompany.myChannel.model.FFSampleRequestHttp" object-mapper="jackson2JsonObjectMapper" /&gt; 
  
  &lt;bean id="jackson2JsonObjectMapper" class="org.springframework.integration.support.json.Jackson2JsonObjectMapper" /&gt; 
  &lt;bean id="ffSampleRequestHttp" class="com.myCompany.myChannel.model.FFSampleRequestHttp" /&gt; 
  &lt;bean id="ffSampleResponseHttp" class="com.myCompany.myChannel.model.FFSampleResponseHttp" /&gt; 
  &lt;/beans&gt;
  </code></pre>
  
  <p>Out bound file config(file which is responsible to sent message to server):</p>
  
  <pre><code>&lt;int:gateway id="requestGateway" service-interface="com.myCompany.myChannel.Common.RequestGateway" default-request-channel="requestChannel" /&gt; 
    &lt;int:channel id="requestChannel" /&gt; 
    &lt;int:channel id="requestChannel1" /&gt; 
    &lt;int:object-to-json-transformer input-channel="requestChannel" output-channel="requestChannel1" content-type="application/json" /&gt; 
    &lt;int-http:outbound-gateway request-channel="requestChannel1" reply-channel="channel4" url="http://localhost:8080/myChannel_prj-1.0.0.BUILD-SNAPSHOT/http/receiveGateway" http-method="POST" /&gt; 
    &lt;bean id="FFSampleRequestHttp" class="com.myCompany.myChannel.model.FFSampleRequestHttp" /&gt; 
    &lt;int:json-to-object-transformer input-channel="channel4" output-channel="requestChannel" type="com.myCompany.myChannel.model.FFSampleResponseHttp" object-mapper="jackson2JsonObjectMapper" /&gt; 
    &lt;bean id="jackson2JsonObjectMapper" class="org.springframework.integration.support.json.Jackson2JsonObjectMapper" /&gt; 
    &lt;/beans&gt;
  </code></pre>
  
  <p>My impl class method is as below:</p>
  
  <pre><code>public  FfSampleResponseHttp issueResponseFor(FfSampleRequestHttp request) {
  
          FfSampleResponseHttp ffSampleResponse2 = new FfSampleResponseHttp();
  
          ffSampleResponse2.setCifNumber("Yappi I am in the method");
          log.info("issueResponseFor(FfSampleRequesthttp request)");
  
          return ffSampleResponse2;
  
      }
  </code></pre>
  
  <p>I am able to call my service method issueResponseFor present in server side from the client but when this is processing further:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: 'json' argument must be an instance of: [class java.lang.String, class [B, class java.io.File, class java.net.URL, class java.io.InputStream, class java.io.Reader]
         at org.springframework.integration.support.json.Jackson2JsonObjectMapper.fromJson(Jackson2JsonObjectMapper.java:93)
         at org.springframework.integration.support.json.Jackson2JsonObjectMapper.fromJson(Jackson2JsonObjectMapper.java:44)
         at org.springframework.integration.support.json.AbstractJacksonJsonObjectMapper.fromJson(AbstractJacksonJsonObjectMapper.java:55)
         at org.springframework.integration.json.JsonToObjectTransformer.doTransform(JsonToObjectTransformer.java:78)
         at org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:33)
         ... 54 more
  </code></pre>
  
  <p>I have verified while debugging that the payload body while in response is coming blank in json object in the parameter of Jackson2JsonObjectMapper.fromJson(…) after roaming through my service method successfully. I am not able to understand where am I doing the mistake. Please provide your help/input.
  Again let me know if I am again missing something in my config files. Thank you very much for your support.</p>