title: Multiple return type in Jersey Client request
body: <p>I'm using Jersey Client API in the following way :-</p>
  
  <pre><code>User user = webRsrc.accept(MediaType.APPLICATION_XML).post(User.class, usr);
  </code></pre>
  
  <p>So I'm expecting the response in object of User class which is a JAXB annotated class.
  However, at times I might also get an error xml and for that I've created a JAXB class ErrorResponse. </p>
  
  <p>Now the problem is that if my request returns an object of ErrorResponse instead of User how can I handle that ?</p>
  
  <p>I tried like this - </p>
  
  <pre><code>ClientResponse response=null;
  try {
  
          response = webRsrc.accept(MediaType.APPLICATION_XML).post(ClientResponse.class,usr);
          User usr = response.getEntity(User.class);    
      }catch(Exception exp)
      {
         ErrorResponse err = response.getEntity(ErrorResponse.class);    
      }
  </code></pre>
  
  <p>But when I try to use getEntity() in catch block, it throws following exception</p>
  
  <pre><code>[org.xml.sax.SAXParseException: Premature end of file.]
  at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:107)
  at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:532)
  at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:491) .....
  </code></pre>
  
  <p>Seems like after calling getEntity() once, the inputstream is exhausted.</p>