I am currently using Jersey as a REST proxy to call another RESTful web service. Some calls will be transferred with minimal processing on my server.
Is there any way to do this cleanly? I thought of using a Jersey client to make a REST call, and then convert ClientResponse into a response. Is this possible or is there a better way to do this?
Code example:
@GET @Path("/groups/{ownerID}") @Produces("application/xml") public String getDomainGroups(@PathParam("ownerID") String ownerID) { WebResource r = client.resource(URL_BASE + "/" + URL_GET_GROUPS + "/" + ownerID); String resp = r.get(String.class); return resp; }
This works if the answer was always successful, but if there is 404 on the other server, I will need to check the response code. In other words, is there a clean way to return the answer I have?
source share