Hi,

I have been doing a lot of reading and experimenting. Unfortuantely, did not
succeed in applying that to my task till now.Yes, that is one thing that I
thought too of doing, "use multiparts to pass the binary payloads only and
other parameters - via the request URI", but I do not want to send pass
parameters in URI, but in the body either as xml or json.I finally came up
with this API, the data required to generate the doc is a string, hence it
can be part of the entity DocumentParameters. 

        @POST
        @Path("/generateDocument/")
        @Produces("multipart/mixed")
        @Consumes("application/xml")
        public MultipartBody generateDocument(DocumentParameters docParams);

But the generated doc could be a pdf/doc or something else; so I guess I
will have to use the MultipartBody.How will the consumer know the name of
the attachment to get from the multipartbody. The return type in the API
above is not very intuitive. I am sure there must be a better way of saying
that the method returns a binary content, which can be accessed by some name
like 'xyz'. Moreover if something goes wrong during doc generation I just
dont want an exception to be thrown, a proper message with an error code is
to be thrown. Although the error handling can be represented as an entity
and attached within MultipartBody, how do I advertise it to the consumer,
that the MultipartBody that is being returned, could contain for exmaple an
entity called ErrorType(in case of an error) or the binary content itself by
some name in case of success?

I hope I am clear enough in explaining what I am trying to do.
Thanks in advance,
Priya




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Best-way-to-send-and-receive-a-document-from-a-resource-method-in-rest-based-webservice-tp5745338p5745402.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to