users@jersey.java.net

[Jersey] Re: how to return Boolean without use of a wrapper class from Jersey service endpoint

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 01 Nov 2011 22:08:26 +0100

Hi Gary,

I would consider just returning a String representation,
which should work for you out of the box (text/plain should be used as
media type here) :

return myBoolean == null ? "null" : myBoolean.toString();

the above could also be used to generate a XML representation,
if you do not want to bother with implementing your own
message body writer for Boolean (see [1] for an example):

@Produces("application/xml")
public String myMethod() {
  ...
  return "<booleanValue>" + seeAbove + "</booleanValue>";
}

But this Boolean->XML stuff IMHO only adds an unnecessary overhead.

HTH,

~Jakub

[1]http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/entity-provider/1.10-b05/entity-provider-1.10-b05-project.zip

On 1.11.2011 14:54, emiddio-frontier wrote:
> my jersey client/service uses application/xml
> it complains about no message body readers/writers ?-- if i remember
> correctly,
> i want to Return a Boolean, i did not try to return boolean yet.
> when i make a container class with proper jaxb xmlRoot markup
> annotations things work,
> but How to simply return a boolean value.
> Thanks
> -Gary