You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by kpalania <kp...@yahoo.com> on 2008/12/31 05:35:11 UTC

FormParam support and usage..

I am using CXF-2.1.2 and I don't believe this has support for @FormParam
since it uses jsr-311*.jar version 0.8 (as opposed to 0.10). I have a need
to POST a large piece of content (over 4K) via the RESTful Services and I
believe I would need to use the FormParam. First of all, is that right?
Where can I get the extension JAR and could someone also give me a sample
Client call?
-- 
View this message in context: http://www.nabble.com/FormParam-support-and-usage..-tp21227224p21227224.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: FormParam support and usage..

Posted by Sergey Beryozkin <se...@progress.com>.
Hi

>
> Thanks Sergey. I tried using JAX-WS Endpoints and implementing the
> Provider<DOMSource> Interface and that seems to work but I would rather
> stick with the RESTful approach if I can.

Using JAXWS Provider<Source> is just one way to write restful services.
As I mentioned a couple of times before we did one project where JAXWS Provider<StreamSource> was used - it does require a bit more 
effort on the developer's side though. For the record, we also used Provider<DataSource> to deal with multiparts, but using 
Provider<StreamSource> will do, see [1] for one example :

As far as a client call is concerned, you just need to associate a (post) body with a PostRequest (if HttpClient is used), but you 
can do it with plain Java HttpURLConnection too

Cheers, Sergey

[1] 
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/AttachmentStreamSourceXMLProvider.java

> In your second example here with
> an InputStream, could you let me know how the Client call would be? Thanks.
>
>
> Sergey Beryozkin-2 wrote:
>>
>> Hi
>>
>> As Arul said, 2.2-SNAPSHOT supports jax-rs 1.0 api so FormParams can be
>> used.
>>
>> I'm not certain that FormParams is what you need for your scenario - as
>> far as I understand it's mostly an alternative to using a
>> MultivaluedMap.
>> But if you do submit data from an html form then with 2.1.2 you just
>> might want to do:
>>
>> @Post
>> @ConsumeMime(MediaType.APPLICATION_FORM_URLENCODED)
>> public void someMethod(MultivaluedMap) {}
>>
>> Another option is to use multiparts - currently you'd need to use
>> InputStream and proceed from there :
>>
>> @Post
>> public void someMethod(InputStream) {}
>>
>> In 2.2 we'll try to offer a better support for dealing with attachments,
>> DataSource will most likely be supported at the least.
>>
>> Cheers, Sergey
>>
>> -----Original Message-----
>> From: kpalania [mailto:kpalania@yahoo.com]
>> Sent: 31 December 2008 04:35
>> To: users@cxf.apache.org
>> Subject: FormParam support and usage..
>>
>>
>> I am using CXF-2.1.2 and I don't believe this has support for @FormParam
>> since it uses jsr-311*.jar version 0.8 (as opposed to 0.10). I have a
>> need
>> to POST a large piece of content (over 4K) via the RESTful Services and
>> I
>> believe I would need to use the FormParam. First of all, is that right?
>> Where can I get the extension JAR and could someone also give me a
>> sample
>> Client call?
>> -- 
>> View this message in context:
>> http://www.nabble.com/FormParam-support-and-usage..-tp21227224p21227224.
>> html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/FormParam-support-and-usage..-tp21227224p21233638.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 


RE: FormParam support and usage..

Posted by kpalania <kp...@yahoo.com>.
Thanks Sergey. I tried using JAX-WS Endpoints and implementing the
Provider<DOMSource> Interface and that seems to work but I would rather
stick with the RESTful approach if I can. In your second example here with
an InputStream, could you let me know how the Client call would be? Thanks.


Sergey Beryozkin-2 wrote:
> 
> Hi
> 
> As Arul said, 2.2-SNAPSHOT supports jax-rs 1.0 api so FormParams can be
> used. 
> 
> I'm not certain that FormParams is what you need for your scenario - as
> far as I understand it's mostly an alternative to using a
> MultivaluedMap.
> But if you do submit data from an html form then with 2.1.2 you just
> might want to do:
> 
> @Post
> @ConsumeMime(MediaType.APPLICATION_FORM_URLENCODED)
> public void someMethod(MultivaluedMap) {}  
> 
> Another option is to use multiparts - currently you'd need to use
> InputStream and proceed from there :
>    
> @Post
> public void someMethod(InputStream) {}
> 
> In 2.2 we'll try to offer a better support for dealing with attachments,
> DataSource will most likely be supported at the least.
> 
> Cheers, Sergey
> 
> -----Original Message-----
> From: kpalania [mailto:kpalania@yahoo.com] 
> Sent: 31 December 2008 04:35
> To: users@cxf.apache.org
> Subject: FormParam support and usage..
> 
> 
> I am using CXF-2.1.2 and I don't believe this has support for @FormParam
> since it uses jsr-311*.jar version 0.8 (as opposed to 0.10). I have a
> need
> to POST a large piece of content (over 4K) via the RESTful Services and
> I
> believe I would need to use the FormParam. First of all, is that right?
> Where can I get the extension JAR and could someone also give me a
> sample
> Client call?
> -- 
> View this message in context:
> http://www.nabble.com/FormParam-support-and-usage..-tp21227224p21227224.
> html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/FormParam-support-and-usage..-tp21227224p21233638.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: FormParam support and usage..

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

As Arul said, 2.2-SNAPSHOT supports jax-rs 1.0 api so FormParams can be
used. 

I'm not certain that FormParams is what you need for your scenario - as
far as I understand it's mostly an alternative to using a
MultivaluedMap.
But if you do submit data from an html form then with 2.1.2 you just
might want to do:

@Post
@ConsumeMime(MediaType.APPLICATION_FORM_URLENCODED)
public void someMethod(MultivaluedMap) {}  

Another option is to use multiparts - currently you'd need to use
InputStream and proceed from there :
   
@Post
public void someMethod(InputStream) {}

In 2.2 we'll try to offer a better support for dealing with attachments,
DataSource will most likely be supported at the least.

Cheers, Sergey

-----Original Message-----
From: kpalania [mailto:kpalania@yahoo.com] 
Sent: 31 December 2008 04:35
To: users@cxf.apache.org
Subject: FormParam support and usage..


I am using CXF-2.1.2 and I don't believe this has support for @FormParam
since it uses jsr-311*.jar version 0.8 (as opposed to 0.10). I have a
need
to POST a large piece of content (over 4K) via the RESTful Services and
I
believe I would need to use the FormParam. First of all, is that right?
Where can I get the extension JAR and could someone also give me a
sample
Client call?
-- 
View this message in context:
http://www.nabble.com/FormParam-support-and-usage..-tp21227224p21227224.
html
Sent from the cxf-user mailing list archive at Nabble.com.