> -----Original Message----- > From: Sergey Beryozkin [mailto:sberyoz...@gmail.com] > Sent: Tuesday, March 06, 2012 1:53 PM > To: users@cxf.apache.org > Subject: Re: How to pass POST parameters with WebClient.post()? > > Hi, > On 06/03/12 20:37, KARR, DAVID wrote: > >> -----Original Message----- > >> From: KARR, DAVID > >> Sent: Tuesday, March 06, 2012 12:32 PM > >> To: users@cxf.apache.org > >> Subject: RE: How to pass POST parameters with WebClient.post()? > >> > >>> -----Original Message----- > >>> From: Sergey Beryozkin [mailto:sberyoz...@gmail.com] > >>> Sent: Tuesday, March 06, 2012 2:06 AM > >>> To: users@cxf.apache.org > >>> Subject: Re: How to pass POST parameters with WebClient.post()? > >>> > >>> Hi > >>> On 05/03/12 23:52, KARR, DAVID wrote: > >>>> I'm working with a developer who is trying to call a REST service > >>> from his code. The service can accept a query parameter that could > >>> potentially be very long. It's easy enough to make this call with > a > >>> GET, but we'd like to avoid the risk of a too-long URL by using a > >> POST > >>> instead. I don't understand how to add POST parameters. > >>> > >>> You can get the query parameters added with POST too, but most > likely > >>> in > >>> this case the requirement is to POST the data using the > >>> "application/x-www-form-urlencoded" media type. > >>> With WebClient you can do it like this: > >>> > >>> import org.apache.cxf.jaxrs.ext.form.Form; > >>> > >>> WebClient wc = WebClient.create(address); > >>> wc.form(new Form().set("a", aValue).set("b", bValue)); > >> > >> Continuing with this, if the only data we have to send are in the > form > >> parameters, what would we send in the final "post()" call? It takes > an > >> Object. What is sent there? > > > > Actually, I guess I figured this out. We would just pass "null" for > that parameter. > .form() is the wrapper around the final post(...), so if you do > webClient.form(form) then that should be it. MultivaluedMap can also be > passed to form(...) > > Alternatively you can do > > webClient.type("application/x-www-form-urlencoded"); > SomeResponse resp = web.post(new Form(), SomeResponse.class);
Is it really necessary to set the MIME type at that point?