title: Spring Integration - how to send POST parameters with http outbound-gateway
body: <p>I'm trying to put together a really simple HTTP POST example using Spring Integration and a http outbound-gateway.<br>
  I need to be able to send a HTTP POST message with some POST parameters, as I would with <code>curl</code>:</p>
  
  <pre><code>$ curl -d 'fName=Fred&amp;sName=Bloggs' http://localhost
  </code></pre>
  
  <p>I can get it working (without the POST parameters) if I send a simple <code>String</code> as the argument to the interface method, but I need to send a pojo, where each property of the pojo becomes a POST parameter.</p>
  
  <p>I have the following SI config:</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="RequestGateway"
               default-request-channel="requestChannel"/&gt;
  
      &lt;int:channel id="requestChannel"/&gt;
  
      &lt;int-http:outbound-gateway request-channel="requestChannel"
                             url="http://localhost"
                             http-method="POST"
                             expected-response-type="java.lang.String"/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My <code>RequestGateway</code> interface looks like this:</p>
  
  <pre><code>public interface RequestGateway {
      String echo(Pojo request);
  }
  </code></pre>
  
  <p>My <code>Pojo</code> class looks like this:</p>
  
  <pre><code>public class Pojo {
      private String fName;
      private String sName;
  
      public Pojo(String fName, String sName) {
          this.fName = fName;
          this.sName = sName;
      }
  
      .... getters and setters
  }
  </code></pre>
  
  <p>And my class to kick it all off looks like this:</p>
  
  <pre><code>public class HttpClientDemo {
  
      public static void main(String[] args) {
          ApplicationContext context = new ClassPathXmlApplicationContext("/si-email-context.xml");
          RequestGateway requestGateway = context.getBean("requestGateway", RequestGateway.class);
  
          Pojo pojo = new Pojo("Fred", "Bloggs");
          String reply = requestGateway.echo(pojo);
          System.out.println("Replied with: " + reply);
      }
  }
  </code></pre>
  
  <p>When I run the above, I get:</p>
  
  <pre><code>org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [Pojo] and content type [application/x-java-serialized-object]
  </code></pre>
  
  <p>I've googled a lot for this, but cannot find any examples of sending HTTP POST parameters with an outbound-gateway (I can find lots about setting HTTP Headers, but that's not what I'm trying to do here)<br>
  The only thing I did find was <a href="https://stackoverflow.com/questions/20083604/spring-integration-how-to-pass-post-request-parameters-to-http-outbound">spring-integration: how to pass post request parameters to http-outbound</a> but it's a slightly different use case as the OP was trying to send a JSON representation of his pojo which I am not, and the answer talks about setting headers, not POST parameters.</p>
  
  <p>Any help with this would be very much appreciated;<br>
  Thanks<br>
  Nathan</p>