Hi.
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.
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.
@Path("somepath")
public class ClassToReturnXML
{
public Response methodToReturnXML()
{
ResponseBuilder builder = new ResponseBuilderImpl();
builder.type(MediaType.TEXT_XML);
builder.entity(myXMLString);
return builder.build();
}
}
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:
ResponseBuilder builder = Response.status(200);
Please suggest what is the apt way to return XML in response.
I AM USING APACHE CXF for RESTFUL SERVICES. (Version 2.2.3 -- i guess) :D Thanks in Advance for all the help.