title: RESTful WebService consumes XML,how to call it?
body: <p><strong>UPDATE</strong></p>
  
  <p>I have almost been able to complete my RESTful communication, though I have to questions remaining:</p>
  
  <p>1 - How do I assign my XML to the connection (the code below will give an example of my situation)?</p>
  
  <p><em>Calling the Web Service</em></p>
  
  <pre><code>public Person getByAccount(Account account) {   
      URL url = new URL(uri);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("GET");
      connection.setRequestProperty("Accept", "application/xml");
  
      XStream xstream = new XStream();
      String xmlIn = xstream.toXML(account);
  
      // Put the xmlIn into the connection
  
      BufferedReader br = new BufferedReader(new InputStreamReader(
          (connection.getInputStream())));
  
      StringBuilder sb = new StringBuilder();
      String line;
      while((line = br.readLine()) != null)
          sb.append(line);
      String xmlOut = sb.toString();
  
      connection.disconnect();
      return (Person) xstream.fromXML(xmlOut);
  }
  </code></pre>
  
  <p>2 - Will the class below result in a valid XML-output, considering the last code example (the Web Service)?</p>
  
  <p><em>Class to send using RESTful</em></p>
  
  <pre><code>@XmlRootElement(name="people")
  public class People {
      @XmlElement(name="person")
      public List&lt;Person&gt; people;
  
      public People() {
          people.add(new Person(1, "Jan"));
          people.add(new Person(2, "Hans"));
          people.add(new Person(3, "Sjaak"));
      }
  
      public List&lt;Person&gt; all() {
          return people;
      }
  
      public Person byName(String name) {
          for(Person person : people)
              if(person.name.equals(name))
                  return person;
  
          return null;
      }
  
      public void add(Person person) {
          people.add(person);
      }
  
      public Person update(Person person) {
          for(int i = 0; i &lt; people.size(); i++)
              if(person.id == people.get(i).id) {
                  people.set(i, person);
                  return person;
              }
  
          return null;
      }
  
      public void remove(Person person) {
          people.remove(person);
      }
  }
  </code></pre>
  
  <p><em>Web Service</em></p>
  
  <pre><code>@GET
  @Path("/byAccount")
  @Consumes("application/xml")
  @Produces("application/xml")
  public Person getByAccount(Account account) {
      // business logic
      return person;
  }
  </code></pre>