Hi
On 01/08/12 10:56, Michael Prieß wrote:
Hi,

have anyone a example how I can use different return types in JAX-RS?

Pseudocode:

@GET
public ? getMessage() {

if(IsBinary) {
  return binary;
}

return xml;
}

Something like this should do

@GET
public javax.ws.rs.core.Response getMessage() {

    ResponseBuilder rb = Response.ok();
    if (isBinary()) {
        // set application/octet-stream or one of multipart types
        rb.type("application/octet-stream");
    } else {
        rb.type("application/xml");
    }
    rb.entity(getResponseObject());
    return rb.build();
}

Cheers, Sergey


Cheers,

Michael

Reply via email to