KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have successfully set up a quick test of creating a "REST-like" service that returns an object serialized to JSON, and that was quite easy and quick (based on this article ). But while returning JSON-ified objects was easy as peach, I have yet to see any examples dealing with input parameters that are not primitives. How can I pass in a complex object as an argument? I am using Apache CXF, but examples using other frameworks like Jackson are welcome too :) Client side would probably be something like building a javascript object, pass it into JSON.stringify(complexObj), and pass that string as one of the parameters. The service would probably look something like this @Service("myService") class RestService { @GET @Produces("application/json") @Path("/fooBar") public Result fooBar(@QueryParam("foo") double foo, @QueryParam("bar") double bar, @QueryParam("object") MyComplex object) throws WebServiceException { ... } } Sending serialized objects as parameters would probably quickly touch the 2KB URL-limit imposed by Internet Explorer. Would you recommend using POST in these cases, and would I need to change much in the function definitions?
Tags (comma-separated)
Save Edits
Cancel