title: POST request (GWT : Requestbuilder). Wrong content type : application/x-www-form-urlencoded instead of application/xml
body: <p>I want to call my REST service on the client side (GWT) using RequestBuilder. I need to serialize a complex type (Connexion), i chose Piriti. The serialization seems to work fine.
  Then i attach the string representation of my complex object to the body's request and send the POST request.</p>
  <p>But i have the following error :</p>
  <blockquote>
  <p>org.jboss.resteasy.spi.BadRequestException: Could not find message body reader for type: class com.ald.projet.property.Connexion of content type: application/x-www-form-urlencoded</p>
  </blockquote>
  <p>I use RESTeasy on the server-side, it seems that it doesn't receive the correct content type.</p>
  <p>I checked with firebug, the content type of my request is application/xml ...not application/x-www-form-urlencoded</p>
  <blockquote>
  <pre><code>Request headers
   Host: 127.0.0.1:8888
   User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
   Accept: application/xml
   Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
   Accept-Encoding: gzip, deflate
   Connection: keep-alive
   Referer: http://127.0.0.1:8888/Front_End.html?gwt.codesvr=127.0.0.1:9997
   Content-Type: application/xml; charset=UTF-8
   Content-Length: 109
   Pragma: no-cache
   Cache-Control: no-cache
  
  Response headers
    Content-Type: text/html; charset=iso-8859-1
    Server  Jetty(6.1.x)
  </code></pre>
  </blockquote>
  
  <p>POST content</p>
  <pre><code>&lt;connexion&gt;
    &lt;login&gt;azerty&lt;/login&gt;
    &lt;password&gt;azerty&lt;/password&gt;
  &lt;/connexion&gt;
  </code></pre>
  <p><strong>Client-side</strong></p>
  <pre class="lang-java prettyprint-override"><code>    Connexion connexion = new Connexion(&quot;azerty&quot;, &quot;azerty&quot;);
  
      String url =&quot;proxy.jsp?url=&quot; + URL.encode(&quot;http://localhost:8080/rest/service/connexion&quot;);
      RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
  
      builder.setHeader(&quot;Content-Type&quot;, &quot;application/xml&quot;);
      builder.setHeader(&quot;Accept&quot;, &quot;application/xml&quot;); 
  
      //serialization with Piriti     
      String xml = Connexion.WRITER.toXml(connexion);
      builder.setRequestData(xml);
  
      builder.setCallback(new RequestCallback() {
  
          @Override
          public void onResponseReceived(Request request, Response response) {
              GWT.log(response.getText());
              System.out.println(response.getText().trim());
          }
  
          @Override
          public void onError(Request request, Throwable exception) {
          }
      });
  
      try{
          builder.send();
      }catch(Exception e){
          e.printStackTrace();
      }
  }
  </code></pre>
  <p><strong>Rest Service (server side)</strong></p>
  <pre class="lang-java prettyprint-override"><code>@POST
  @Path(&quot;/connexion&quot;)
  //@Consumes(&quot;application/xml&quot;)
  @Produces(&quot;application/xml&quot;)
  public Response connexion(Connexion connexion){
      String status = connexionDAO.isValidConnection(connexion);
      
      return Response.ok(status).build();
      
  }
  </code></pre>
  <p><strong>Connexion.java</strong> client side</p>
  <pre class="lang-java prettyprint-override"><code>public class Connexion {
  
  interface ConnexionReader extends XmlReader&lt;Connexion&gt; {}
  public static final ConnexionReader XML = GWT.create(ConnexionReader.class);
  
  
  public interface ConnexionWriter extends XmlWriter&lt;Connexion&gt; {}
  public static final ConnexionWriter WRITER = GWT.create(ConnexionWriter.class);
  
  
  private String login;
  private String password;
  
  public Connexion(){
      
  }
  
  
  public Connexion(String login, String password) {
      super();
      this.login = login;
      this.password = password;
  }
  public String getLogin() {
      return login;
  }
  public void setLogin(String login) {
      this.login = login;
  }
  public String getPassword() {
      return password;
  }
  public void setPassword(String password) {
      this.password = password;
  }   
  </code></pre>
  <p>}</p>
  <p><strong>Connexion.java</strong> server side</p>
  <pre class="lang-java prettyprint-override"><code>@Embeddable
  @XmlRootElement(name = &quot;connexion&quot;)
  public class Connexion {
  
  private String login;
  private String password;
  
  public Connexion(){
      
  }
  
  public Connexion(String login, String password) {
      super();
      this.login = login;
      this.password = password;
  }
  
  @XmlElement
  public String getLogin() {
      return login;
  }
  public void setLogin(String login) {
      this.login = login;
  }
  
  @XmlElement
  public String getPassword() {
      return password;
  }
  public void setPassword(String password) {
      this.password = password;
  }   
  </code></pre>
  <p>}</p>
  <p>what is happening and what can i do in order to make it work ?</p>
  <p>Thx in advance</p>