• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpResponse assign to class with @XmlRootElement?  RSS feed

 
Gabriela Rios
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to RESTful Web Services. I created one and now I'm working on the client but I'm confused on how to turn my xml into my object.

I have my response of the type org.apache.http.HttpResponse. It looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><User><address>XXX</address><firstname>Gabriela</firstname></User>

I have my class User with @XmlRootElement. How do i turn that xml into my class.
In here, http://cxf.apache.org/docs/jax-rs-data-bindings.html, they show how to do it but they never really assign the response to the Customer or Customers.

I also found this, http://www.mkyong.com/webservices/jax-rs/restful-java-client-with-apache-httpclient/, but it produces a string rather than xml. I would like to find an example like this where instead of using json they use xml.

I would like to know how do they do something like this?

HttpResponse result = httpclient.execute(get);
User user = magicFunction(result);

Can somebody point in the right direction please?

Thanks,



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!