0

I'm a bit new to JAX-RS.

I have the following code:

Client client = ClientBuilder.newClient();

WebTarget resource = client.target("/foo/bar/" + id);

final String xml = resource.request(MediaType.APPLICATION_XML).get(String.class);

This is a stupid question, but how exactly could I get the response and it's status code from here? The output is a String...

carlspring
  • 31,231
  • 29
  • 115
  • 197
  • Please take a look at this link: http://stackoverflow.com/questions/4687271/jax-rs-how-to-return-json-and-http-status-code-together – Ryan Fung Nov 09 '14 at 23:54
  • The thing is -- on the server-side I am returning a object (`Foo`) which is automatically marshalled by `Jersey` + `Jackson`. – carlspring Nov 10 '14 at 00:46

1 Answers1

4
Invocation.Builder builder = resource.request(MediaType.APPLICATION_XML);
Response resp = builder.get ();
int status = resp.getStatus ();
String xml = resp.getEntity (String.class);
Steve Siebert
  • 1,874
  • 12
  • 18