I am writing a RESTful web service where I want to return XML containing some set of results. I used XSTREAM and parsed the object in an XML string. Since I need to return this string, I need to know how to pass it to the calling client.
One way is to return RESPONSE to the calling client. And my sample code shows what I'm 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 does not return an object, although the status code is 200. I am not creating the ResponseBuilder instance incorrectly? I also saw somewhere that it should be created as follows:
ResponseBuilder builder = Response.status(200);
Please suggest which way to return the XML in response.
I use APACHE CXF for RELATIVE SERVICES. (Version 2.2.3 - I think): D
Thanks in Advance for the help.