2

I am using Jersey/Tomcat6 for dveloping some web services. Compared to what I did for SOAP services, I am not getting the idea what should I share to my clients once the services are developed...just the URL of the web service ?? For SOAP, the WSDL file was enough, as the clients self-generated the stubs.

My service returns a list of User objects (with 2 Strings) in JSON format. How would my clients de-serialize the JSON if I share just the service URL with them ? Do I need to share the entity bean (The User class, and the list class) on my server side too ?

I have been reading about some WADL files for REST...are they helpful here ?

Thanks for any help !

skaffman
  • 398,947
  • 96
  • 818
  • 769
zombie
  • 265
  • 7
  • 16

1 Answers1

0

It sounds like you probably want to put together an example client to give to your, er, clients to show them how to use the REST service. Ideally, of course, your REST service would fully support HATEOAS (Hypermedia As The Engine Of Application State), and so the means of traversing the resources to get the desired results would be discoverable; I've found that real HATEOAS implementation is rare, though. For a RESTful-ish service (one that doesn't fully support HATEOAS), example clients are useful. You can usually implement your example client in HTML with some Javascript; this makes everything very accessible for most REST client users.

Paul Sonier
  • 38,903
  • 3
  • 77
  • 117
  • 1
    I can make some clients using Jersey again..but they too need the class files after deserializing the JSON I send over the network. So my question is that, do I need o pass on these clas files to all my clients ? (Coz, I as a client really do need these classes or object structure). – zombie Jul 07 '11 at 18:00
  • Here's the question: precisely why do your clients need the classes? – Paul Sonier Jul 07 '11 at 18:42
  • I guess I am horribly wrng somewhere. The jersey client I made receives a JSON string from the web service - which it needs to de-serialize into an object. This "de-serialization" needs an existing class definition (same as that on the server side). Where am I wrong ? Can my client deserialize the whole JSON string without even knowing the class file ?? – zombie Jul 07 '11 at 19:12
  • They shouldn't need your classes at all to make use of the JSON representation of your class. If the JSON being generated is tightly coupled to some java class implementation such that it doesn't make sense without that particular implementation, then it should probably be changed. Can you post a sample of the JSON? – stinkymatt Jul 08 '11 at 11:06
  • @zombie Your assumption "which it needs to de-serialize into an object" is constraining the client developer to a particular implementation methodology. You shouldn't care how the client developer chooses to de-serialize your media-type. You are free to show examples of how they _might_ do it. However, try not limit them. – Darrel Miller Jul 09 '11 at 01:32