title: Java Jersey PUT Method and working Client
body: <p>I am developing an Dynamic Web Application with Eclipse. I have e working MySQL-Database which is connected over a class called 'Data Access Object' (=DAO) that works with JDBC. I want to create entries into this database. The functions are ready. With ready I mean tested and OK. On the same application I implemented Java Jersey's RESTful WebService. It is working well, I can call the service and it returns my desired information. But now to my question:</p>
  
  <p>How can I send a String containing XML? The String has to be parsed in the WebMethod to build and execute the query.</p>
  
  <p>My WebService looks as follows:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  
  import javax.ws.rs.Consumes;
  import javax.ws.rs.PUT;
  import javax.ws.rs.Path;
  import javax.ws.rs.core.MediaType;
  
  @Path("/input")
  public class Input {
      //DAO instance to have connection to the database.
      //Not used yet.
      //private DAO dao = new DAO();
  
      @PUT
      @Consumes(MediaType.TEXT_XML)
      @Path("/result")
      public void putIntoDAO(InputStream xml) {
          String line = "";
          StringBuilder sb = new  StringBuilder();
          try {
              BufferedReader br = new BufferedReader(new InputStreamReader(xml));
              while ((line = br.readLine()) != null) {
                  sb.append(line);
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
          System.out.println(sb.toString());
      }
  }
  </code></pre>
  
  <p>As you see I tried to print the incoming Stream to the console.
  <strong>I repeat the most important things:</strong></p>
  
  <ul>
  <li>I know how to parse XML.</li>
  <li>I know my DAO works properly.</li>
  <li>I know my WebService works as well.</li>
  </ul>
  
  <p><strong>What I would like to know:</strong></p>
  
  <ul>
  <li>How do I send an XML-String to my WebService?</li>
  <li>How do I access this String in my PUT-method?</li>
  </ul>
  
  <p>Thank you for your attention and try to help me. I appreciate even every try to.</p>
  
  <p>Kind regards</p>
  
  <p>L.</p>