1

I am new to the REST framework, and am trying to expose a simple method which requires an array of integers and returns an array of Strings. But I am confused as to what mimetype @Produces and @Consumes on the method should be ? And how should the client get it ??

I have seen ways to use JAXB for sending a complex object via XML/JSON formats ; but I have yet not seen any code for primitives / arrays...can someone please help ?

Plus, I would be grateful if someone can show a similar code for SOAP service also...

Thanks !

PS : I am using Jersey/Java on Eclipse for developing the services.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
dev
  • 11,071
  • 22
  • 74
  • 122

1 Answers1

2

Primitives and arrays are handled automatically. You don't have to do anything special for them.

@Produces and @Consumes are not about the type of object returned. They are about the content type which the service consumes and produces. They do relate to the representation of the object hoever. So if you have @Produces("application/json"), then the framework will use JSON to represent to result.

You can look through the documentation of RESTEasy (in addition to that of Jersey, which I guess you've looked through already). It pretty much covers JAX-RS in a comprehensive manner.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • I am trying to achieve the same, but cant. Can you please share some code ? – dev Jan 27 '11 at 17:28
  • I don't have core right now - did some proof-of-concept with Jersey a while ago. How about you sharing your code and I'll try pointing what's wrong. – Bozho Jan 27 '11 at 19:42