1

I am new to RESTful web services. Please bear with me if I am asking a silly question. I spent several hours on this. But, couldn't come with a solution.

My question is: When I GET the data (using the GET method in my resource) from the database in XML format it returns all the fields(as XmlElement) in my entity. Now, I want to add a resource link within that XML output for each entity, something like this:

<persons> 
  <person>  
    <name>abc</name>  
    <title>xyz</title>
    <personResource>http://localhost:8080/personInfomation/resources/persons/abc
  </person>
  .....
  .....
  .....
  <person>
    <name>efg</name>
    <title>zzz</title>
    <personResource>http://localhost:8080/personInformation/resources/persons/efg
  </person>
</persons>

Could you please tell me how I can achieve this?

I am using Jersey, Oracle and Tomcat for my development.

thanks, Sam.

Sam
  • 11
  • 3
  • I've been looking for an answer to this as well. As far as I can tell, Jersey doesn't have a nice way of doing this without writing lots of duplicate code, but some of the other JAX-RS implementations do. See for example, RESTEasy's solution at http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html_single/index.html#LinkHeader . I would love to see a solution that doesn't require switching from Jersey to RESTEasy, though. – Tyler May 19 '11 at 21:17
  • By the way, the "standard" way of doing this is to use an element like this: ``. or an HTTP header called "Link:" as you can see from my link in my last comment. This idea was kind of borrowed from Atom but it makes a lot of sense for RESTful services in general. – Tyler May 19 '11 at 22:01
  • This question just appeared recently: http://stackoverflow.com/questions/6087382/hypermedia-with-jersey-using-atom – Tyler May 23 '11 at 17:04

0 Answers0