Re: [Resteasy-users] Multipart Form Data + multi-value part
Thanks! On the server-side that's great. I'll use: input.getFormDataMap().get(propertyName); Is there an analog on the client side? Looking at the MultipartFormDataOutput version of getFormData(), it's a map of name to OutputPart (rather than ListOutputPart). As to what I'm trying to do - I'm implementing the OASIS S-RAMP specification, which has an Atom based API binding. The specification stipulates the 'propertyNames' input as a list of values, passed via multipart/form-data. -Eric On 01/10/2013 05:21 PM, Bill Burke wrote: On 1/10/2013 9:41 AM, Eric Wittmann wrote: Greetings. I am trying to get a multi-value input part working in my resteasy service. On the inbound side, I'm expecting a multipart/formdata post, where an input part named propertyName may appear multiple times. I need to read that in as a Collection of some sort. Some sample code that may or may not be right: @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_ATOM_XML_FEED) public Feed queryFromPost(MultipartFormDataInput input) { String query = input.getFormDataPart(query, new GenericTypeString() { }); SetString propNames = input.getFormDataPart(propertyName, new GenericTypeSetString() { }); return doQuery(query, propNames); } qyer is right, propNames is wrong. You'll have to do ListInputPart propNames = input.getFormDataMap().get(propertyName); I'm also using resteasy on the client-side. Not sure how to submit the POST with multiple values. Currently I have: String url = ... String query = ... SetString propertyNames = ... ClientRequest request = new ClientRequest(url); MultipartFormDataOutput formData = new MultipartFormDataOutput(); formData.addFormData(query, query, MediaType.TEXT_PLAIN_TYPE); formData.addFormData(propertyName, propertyNames, MediaType.TEXT_PLAIN_TYPE); The above will try to marshal a SetString into TEXT_PLAIN, which will call Set.toString(). request.body(MediaType.MULTIPART_FORM_DATA_TYPE, formData); ClientResponseFeed response = request.post(Feed.class); Clearly this isn't right. Any thoughts on how this should be done? I'm not exactly sure what you're trying to do? Why not just create your own json or XML media type and send that? What are you using multipart? -- Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users
Re: [Resteasy-users] Multipart Form Data + multi-value part
On 1/10/2013 9:41 AM, Eric Wittmann wrote: Greetings. I am trying to get a multi-value input part working in my resteasy service. On the inbound side, I'm expecting a multipart/formdata post, where an input part named propertyName may appear multiple times. I need to read that in as a Collection of some sort. Some sample code that may or may not be right: @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_ATOM_XML_FEED) public Feed queryFromPost(MultipartFormDataInput input) { String query = input.getFormDataPart(query, new GenericTypeString() { }); SetString propNames = input.getFormDataPart(propertyName, new GenericTypeSetString() { }); return doQuery(query, propNames); } qyer is right, propNames is wrong. You'll have to do ListInputPart propNames = input.getFormDataMap().get(propertyName); I'm also using resteasy on the client-side. Not sure how to submit the POST with multiple values. Currently I have: String url = ... String query = ... SetString propertyNames = ... ClientRequest request = new ClientRequest(url); MultipartFormDataOutput formData = new MultipartFormDataOutput(); formData.addFormData(query, query, MediaType.TEXT_PLAIN_TYPE); formData.addFormData(propertyName, propertyNames, MediaType.TEXT_PLAIN_TYPE); The above will try to marshal a SetString into TEXT_PLAIN, which will call Set.toString(). request.body(MediaType.MULTIPART_FORM_DATA_TYPE, formData); ClientResponseFeed response = request.post(Feed.class); Clearly this isn't right. Any thoughts on how this should be done? I'm not exactly sure what you're trying to do? Why not just create your own json or XML media type and send that? What are you using multipart? -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712 ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users