Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpResponse assign to class with @XmlRootElement?

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

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,, they show how to do it but they never really assign the response to the Customer or Customers.

I also found this,, 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?


  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic