• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Help needed on restful web services

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    You showed up just in time for the waffles! And this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic