• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpResponse assign to class with @XmlRootElement?

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic