aspose file tools
The moose likes Web Services and the fly likes RESTful service - standard output  elements, structure ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "RESTful service - standard output  elements, structure ?" Watch "RESTful service - standard output  elements, structure ?" New topic
Author

RESTful service - standard output elements, structure ?

Mag Wells
Ranch Hand

Joined: Jun 02, 2010
Posts: 38
I am a bit confused about what standard restful service call output is ? I mean for example, my current web service,



This looks pretty ok. But what I am missing is seems the (error)messages from the server, may be the resultset size and things like that. I really have no clue what all addons like these should be included.

Any pointers/samples would be a great help. Also an idea about the gnrl class heirarchy for this to achieve.

-muncher
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
There's no standard of what a REST response looks like. An error message would generally only be returned if there is an error, not if there are results like in your example. If you want metadata, how about a response like this:
Mag Wells
Ranch Hand

Joined: Jun 02, 2010
Posts: 38
yeah, I guess metadata is the right word. Thanks.

Now there are couple of questsions-
1. What would the general metadata look like ?
2. How do I embed that metadata of every response.

Bit of clarification on #2.
I have java objects say for example Book. My spring framework serializes it and converts it to <book> ..... </book>
set of books would be returned as List.
That is <list> <book>..</book><book>..</book><book>..</book><book>..</book></list>
so do I create a new class metadata and make every other class inherit that ?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12265
    
    1
1. Since a response can contain ANY kind of content - XML, binary, whatever, there is no general content metadata.
2. Instead, use the HTTP headers to communicate additional information, thats the whole point of REST, to use the existing HTTP protocol.

For example your response headers should use the correct response code and include a content type and length.

Wikipedial article on response codes

Wikipedial summary of HTTP request and response headers.

Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://jrebel.com/download
 
subject: RESTful service - standard output elements, structure ?
 
Similar Threads
How to create Rest based WEb service
Issues related to RESTful web servicers
SOAP x RESTful WebServices
RESTful Web Services:About the book
[Again]RESTful WS Enterprise