• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help needed on restful web services

 
Jitesh Sinha
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very basic question about rest.
we are designing a rest web service which is supposed to output two values in a single call.How can we do that?I was under impression that by using rest we can only send java.lang.String objects to the client(entity that consumes web service) and get only java.lang.String from clients.I know that all objects will have to be serializable to be transferred over the wire and that is how SOAP works.
Can we do something like this in rest ,wherein we construct a java custom object ,specify a serializer and deserializer and send the java custom object across to the client (and reverse)?

If yes,can I get a sample code?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While HTTP only allows text to be returned as the response body, that text can be a representation of anything.

When complex data needs to be returned, the most common media types used are XML or JSON, which have media types of application/xml and application/json respectively.

Using these formats, you can exchange highly complex data.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you need some fundamental knowledge of REST that you are currently lacking.

I highly recommend reading through a good book on RESTful APIs. A couple I have liked are:
  • RESTful Web Services
  • RESTful Web Services Cookbook


  • The latter I found especially useful for understanding how to define a RESTful API without getting into implementation language or framework specifics.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!