How to parse javax.ws.rs.core.Response

I am having problems understanding how to parse javax.ws.rs.core.Response. Some people have pointed to using an InputStream, but I don’t understand how this works, since the return type response.getEntity () is of type Object. For instance:

Response response = client.target(enpoint).request(MediaType.APPLICATION_XML).get();
InputStream is = response.getEntity();

NetBeans complains and says that I will need to use the Object type for the InputStream. The answer will be XML, and I just want to be able to parse it using the DOM. I am having problems with javax.ws.rs.core.Response for something useful.

Any ideas?

+4
source share
2 answers

API JAX-RS 2.x Response.readEntity(InputStream.class). , - Response,

InputStream is = client.target(enpoint).request(
                            MediaType.APPLICATION_XML).get(InputStream.class);
+4

:

MyResponse myResponse = response.readEntity(MyResponse.class);
+1

All Articles