title: Build a xml post request and accept the response using JSR in java
body: <p>I'm trying to build a rest client as well as a server using Post method. I have created a sample client to submit the rest request.</p>
  
  <pre><code>    public class TestRequests {
  
          public static void main(String[] args) throws Exception {    
          String request = "http://localhost:8080/TestRest/resources/generic/";
  
          HttpClient client = new HttpClient();
          PostMethod method = new PostMethod(request);
  
          method.addParameter("name", "hello");
  
          // Send POST request
          int statusCode = client.executeMethod(method);
          System.out.println("the status code is-----" + statusCode);
          if (statusCode != HttpStatus.SC_OK) {
              System.err.println("Method failed: " + method.getStatusLine());
          }
          InputStream rstream = null;
  
          // Get the response body
          rstream = method.getResponseBodyAsStream();
  
          // Process the response from Yahoo! Web Services
          BufferedReader br = new BufferedReader(new InputStreamReader(rstream));
          String line;
          while ((line = br.readLine()) != null) {
              System.out.println(line);
          }
          br.close();
      }
  
  }
  </code></pre>
  
  <p>I have my server side code where I'm trying read the parameter that I have added. But I'm unable to do so. </p>
  
  <pre><code>@POST
      @Produces("text/plain")
     public String sayHelloPost(@QueryParam ("name") String name) {
          return "Hello World!" + name;
      }
  </code></pre>
  
  <p>Here I'm not able to get the value that I'm sending from my client.</p>
  
  <p>The same with the GET works fine.</p>
  
  <p>Also I'd like to know how to send a xml instead of the string in my request and get the xml in the response. Can a XML Document be sent directly.</p>
  
  <p>Thanks in advance.</p>
  
  <p>-Garudadwajan</p>