title: Return XML Response in REST Service
body: <p>I am writing a RESTful web service where in I want to return a XML containing some resultset. I have used XSTREAM and parsed the object into XML string. Since I need to return this string, I need to know how to pass it back to the calling client. </p>
  
  <p>One way is to return the RESPONSE to the calling client. And my sample code here shows what it is that I am trying to do. </p>
  
  <pre><code>@Path("somepath")
  public class ClassToReturnXML
  {
      public Response methodToReturnXML()
      {
  
         ResponseBuilder builder = new ResponseBuilderImpl();
         builder.type(MediaType.TEXT_XML);
         builder.entity(myXMLString);
         return builder.build();
      }
  }
  </code></pre>
  
  <p>Unfortunately it doesn't return the entity, though the status code is 200. Am I instantiating the ResponseBuilder incorrectly? I also saw somewhere that it should be instantiated as follows:</p>
  
  <pre><code>ResponseBuilder builder = Response.status(200);
  </code></pre>
  
  <p>Please suggest what is the apt way to return XML in response. </p>
  
  <p><strong><em>I AM USING APACHE CXF for RESTFUL SERVICES. (Version 2.2.3 -- i guess) :D</em></strong>
  Thanks in Advance for all the help.</p>