XML : Jersey Client - Get entity with XML

I am trying to implement a generic method in which we get response object as per the class we have passed. So I have a method with signature

  protected <T> T postRequest(String resourceURI,final Object request,Class<T> responseClass)    

In this method I will create a jersey client and execute it, then based on response status I need to construct object something like this.

  T response = jerseyClientResponse.getEntity(responseClass);    

The responseclass is an JAXB compatible pojo. When we hit the resourceURI I can get different XML. For example resource A has A.xml, B have B.xml, if an exception occurred at server then exception.xml. I have POJO JAXB compatible classes for A,B and exception.xml. How can I make the postRequest method generic, so that if we have pojo class to support these xml we will get the response in that particular object. The XML are pretty simple and straight forward.

No comments:

Post a Comment