How do you set the content type in Restlet (version 2.0 for google app engine)? In this case, I'd like to set the content type to ""text/xml".
I have:
public class SubResource extends ServerResource {
@Get
public Representation get(Representation representation){
setStatus(Status.SUCCESS_OK);
StringRepresentation sr = new StringRepresentation(getSomeXml());
return sr;
}
}
I'm unsure even if it is a value that is set in the Representation, or if it is set from the ServerResource class the same way that the return code is.
StringRepresentation sr = new StringRepresentation(getSomeXml());
sr.setMediaType(MediaType.TEXT_XML);
Copying this from some code I wrote a while ago, not sure if things have changed since:
Representation representation = new StringRepresentation(body, MediaType.TEXT_PLAIN);
representation.setCharacterSet(CharacterSet.UTF_8);
return representation;
For your needs, there's also MediaType.TEXT_XML