Hi Kynan


Hi Sergey,

Thanks for the test case links. I had seen your blog (and Arul's) but hadn't
seen these tests yet.

I've got something working but need to think about client support for
generating multipart requests (I mean its easy enough using http client but
i'll probably have all kinds of clients) and if thats the best option etc.

We're definitely planning to do the multiparts support in our client api. I'm hoping it will be just a matter of utilizing a useful CXF AttachmentSerializer, perhaps with minor refactorings to accomodate for various multiparts media types. I might not get a chance to do it in time for 2.2.3 but it will be done for 2.3 for sure.

Perhaps a completely different option, as far as your requirement is concerned, is to move most of that XML complex type into POST URI path/matrix parameters, but have an actual mail body as a request body and thus not to use multiparts. It would work only if you have a single attachment. That said, you should be ok with multiparts too.


As a side note when I was testing POST of a single InputStream I closed the
stream in my service class but that caused an exception to be thrown by the
OutInterceptor because it was trying to close it too. However, I don't seem
to have this behaviour using multiparts. Should input streams typically be
closed by the service class or closed by the runtime?

The service class should not close them. You might want to avoid dealing with InputStream altogether. If you have say a mail root body (or as one of other parts) then you can have say Mail custom reader registered and have Mail in your method signature...

By the way, did you mean JAXRSOutInterceptor when you said OutInterceptor ? I can't recall JAXRSOutInterceptor closing an input stream, it's probably some other CXF interceptor

thanks, Sergey


Thanks for your responses.

Regards,
Kynan


Sergey Beryozkin-2 wrote:

Hi Kynan

I'd probably go with multiparts, CXF is very efficient in the way it deals
with attachments, every part will be represented by an
individual stream, if the part is too large then it will be saved to the
disk, etc...
I'm sorry I haven't properly documented how to use attachments in CXf
JAX-RS, I only posted to my blog once. I'm so slow in updating
the docs. Here's a system test :

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(tests)

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
(resource class)

The limitation is that multiparts are not supproted by the client api - I
have this JIRA for it :
http://issues.apache.org/jira/browse/CXF-2270

 Let me know please if using multiparts can be of interest

cheers, Sergey


----- Original Message ----- From: "Kynan Fraser" <[email protected]>
To: <[email protected]>
Sent: Monday, July 06, 2009 9:03 AM
Subject: Re: JAX-RS: Best approach for POST operation of a complex type
containing binary object



Forgot to mention i've got no problem with byte[]'s in the XML but i'd
prefer
to use streams if possible. I'm not sure if there is a way to have
streams
inside the XML, or if its better to use attachments/multipart instead?

Regards,
Kynan

Kynan Fraser wrote:

Hi All,

My use case is I need to support a POST operation for clients to send an
XML representation of a complex type (like a mail) containing a mix of
strings and (multiple) binary objects (mail attachments).

I can handle a post just containing a single binary as an input stream
or
byte[], or the XML by itself easily enough, but I'm not sure of the best
way to handle them side by side and also multiple binary objects
(ideally
streams?) instead of just one inside the xml complex type. Should they
be
base64 encoded binary objects inside the XML? Attachments?

I've read a bit about jaxrs support for multiparts but i'm not sure if
thats my best option... any help/direction is appreciated.

Thanks,
Kynan


--
View this message in context:
http://www.nabble.com/JAX-RS%3A-Best-approach-for-POST-operation-of-a-complex-type-containing-binary-object-tp24350931p24351262.html
Sent from the cxf-user mailing list archive at Nabble.com.





--
View this message in context: http://www.nabble.com/JAX-RS%3A-Best-approach-for-POST-operation-of-a-complex-type-containing-binary-object-tp24350931p24364644.html
Sent from the cxf-user mailing list archive at Nabble.com.


Reply via email to