title: How do I post XML to RESTFUL Web Service using Net::HTTP::Post?
body: <p>I am having trouble getting this to work so any help would be appreciated! Basically, the request.body contains valid XML for the Web Service like so:</p>
  
  <pre><code>&lt;somedata&gt;
  &lt;name&gt;Test Name 1&lt;/name&gt;
  &lt;description&gt;Some data for Unit testing&lt;/description&gt;
  &lt;/somedata&gt;
  </code></pre>
  
  <p>...but the service returns empty XML. Note that the id field is returned suggesting that it does actually hit the database, but the name and description fields are nil:</p>
  
  <pre><code>&lt;somedata&gt;
  &lt;id type='integer'&gt;1&lt;/id&gt;
  &lt;name nil='true'&gt;&lt;/name&gt;
  &lt;description nil='true'&gt;&lt;/description&gt;
  &lt;/somedata&gt;
  </code></pre>
  
  <p>I have manually tested the RESTFUL service using Poster and it works fine.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>url = URI.parse('http://localhost:3000/someservice/')
  request = Net::HTTP::Post.new(url.path)
  request.body = "&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;somedata&gt;&lt;name&gt;Test Name 1&lt;/name&gt;&lt;description&gt;Some data for Unit testing&lt;/description&gt;&lt;/somedata&gt;"
  response = Net::HTTP.start(url.host, url.port) {|http| http.request(request)}
  
  #Note this test PASSES!
  assert_equal '201 Created', response.get_fields('Status')[0]
  </code></pre>
  
  <p>Does anyone have any clues why the data in the XML post is not persisted?</p>