user325643
user325643

Reputation: 363

Two distinct responses from RESTful web service for a single call

How can I get 2 or multiple responses back from a CXF based RESTFul webservice for a single call.

For example : For this http://localhost:8080/report/annual, I would like to get 2 JSON reponses back. The first one will give me the information about the report details & some other information. The second reponse will give me the actual report JSON. If these 2 be delivered async that will be really good.

Upvotes: 1

Views: 311

Answers (2)

Mike Summers
Mike Summers

Reputation: 2229

I'm with @flesk, this really isn't a REST approach, this is more of an async messaging approach.

The first call should return "someinfo" after it starts the "actualReport" processing (in a separate thread/process since "actualReport" is time consuming). Then make a second call for "actualReport" and make sure the timeout value on that call is set high enough to let the report processing complete.

You could get fancy and loop on the second call, returning a 404 until the report is complete.

There are a number of ways to get what you want, just not with one RESTful call.

Upvotes: 2

flesk
flesk

Reputation: 7579

You can't. Why would you want to do that anyway, when you can just return something like

{"someInfo": {...}, "actualReport": {...}}

Upvotes: 1

Related Questions