You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Priscille Durville <pr...@sophia.inria.fr> on 2009/04/21 11:56:54 UTC
Re: [JAX-RS] pb while passing array as parameter
Hi!
Just a stupid question: is this now included in one of the stable
version that can be donwloaded ? (so that I can update my maven pom)
cheers,
Priscille.
Sergey Beryozkin a écrit :
> Hi
>
> I fixed it on Friday evening but could not merge so merged only
> today...Arrays can now be supported for all the parameter types
> (query, path, header, etc)....There's no need to register a
> ParameterHandler for say String[] or Long[], only needed when we have
> something like Customer[], on which case a ParameterHandler<Customer>
> needed to be registered....
>
> Can you work with a trunk or do you need a snapshot be deployed ?
> You can do a quick local build by follwoing this sequence :
> 1. mvn -Pfastinstall
> 2. cd api
> 3. mvn install (this step is needed because -Pfastinstall in 1. skips
> the javadocs creation in api which causes issues in 5.)
> 4. cd /distribution
> 5. mvn install,
>
> and get the distribution from a target....
>
> cheers, Sergey
>
>
> ----- Original Message ----- From: "Priscille Durville"
> <pr...@sophia.inria.fr>
> To: <us...@cxf.apache.org>
> Sent: Friday, March 27, 2009 3:51 PM
> Subject: Re: [JAX-RS] pb while passing array as parameter
>
>
>> ok! I understand. :-) Thanks a lot!
>> So I will wait for your work :-) because I can't modify the signature
>> of my method (from String[] to List<String>) for internally reasons.
>> Cheers,
>> Priscille.
>>
>>
>> Sergey Beryozkin a écrit :
>>> Hi
>>>
>>> If you change it to List<String> then it should work - but I will do
>>> some work to ensure arrays are supported too
>>> The reason the MessageBodyReader provider is not invoked is that
>>> it's not a request body but a parameter orignated from a request uri.
>>> That's where ParameterHandler CXF extensions can be used, they have
>>> a single fromString() method - but it looks like there's a bug in
>>> the runtime in that they can not be matched against Array classes -
>>> will fix it too :-)
>>>
>>> Cheers, Sergey
>>>
>>>
>>>> Hi!
>>>>
>>>> I have defined (and implemented) the method below :
>>>>
>>>> @WebMethod
>>>> @GET
>>>> @Path("/xxx/")
>>>> @ConsumeMime({"text/plain", "application/xml", "application/json"})
>>>> @ProduceMime({"text/plain", "application/xml", "application/json"})
>>>> public String[] getXXX(@QueryParam("index") String[] index);
>>>>
>>>> My client is an HTML form that contains text inputs with the same
>>>> value for the attribute called "name" like this :
>>>> <input type="text" name="index" value="toto" />
>>>> <input type="text" name="index" value="titi" />
>>>> <input type="text" name="index" value="tutu" />
>>>>
>>>> So the URL is something like this :
>>>> ...?index=toto&index=titi&index=tutu
>>>>
>>>> But it seems that it doesn't work because in this case my method
>>>> would have a List<String> parameter instead...
>>>> So I have modified my form so that URL send is now like this :
>>>> ...?index={"toto", "titi", "tutu"} and I have created a
>>>> MessageBodyReader implementation like this :
>>>> public class StringArrayTextProvider implements
>>>> MessageBodyReader<String[]> { ... }
>>>> that I have registered in my beans.xml like that :
>>>>
>>>> <bean id="StringArrayTextProvider"
>>>> class="mypackage.helpers.StringArrayTextProvider"/>
>>>> <jaxrs:server id="myService" address="/rest/myservice">
>>>> <jaxrs:serviceBeans>
>>>> ...
>>>> </jaxrs:serviceBeans>
>>>> <jaxrs:providers>
>>>> <ref bean="StringArrayTextProvider" />
>>>> </jaxrs:providers>
>>>> </jaxrs:server>
>>>> When sending the URL and calling the service, the index parameter
>>>> received is null and the method "readFrom" of my MessageBodyReader
>>>> is never called. :-(
>>>> Where is my mistake?
>>>>
>>>> Thanks in advance!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> ---------------------------------------------
>>>> Priscille DURVILLE
>>>>
>>>> INRIA
>>>> Equipe Edelweiss (ex Acacia)
>>>>
>>>> priscille.durville@sophia.inria.fr
>>>>
>>>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>>>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>>>> Fax : 04 92 38 77 83
>>>>
>>>> I.N.R.I.A.
>>>> Centre de Recherche Sophia Antipolis - Méditerranée
>>>> 2004 route des Lucioles - B.P. 93
>>>> 06902 Sophia-Antipolis Cedex
>>>> FRANCE
>>>> ---------------------------------------------
>>>>
>>>
>>
>> --
>>
>> ---------------------------------------------
>> Priscille DURVILLE
>>
>> INRIA
>> Equipe Edelweiss (ex Acacia)
>>
>> priscille.durville@sophia.inria.fr
>>
>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>> Fax : 04 92 38 77 83
>>
>> I.N.R.I.A.
>> Centre de Recherche Sophia Antipolis - Méditerranée
>> 2004 route des Lucioles - B.P. 93
>> 06902 Sophia-Antipolis Cedex
>> FRANCE
>> ---------------------------------------------
>>
>
--
---------------------------------------------
Priscille DURVILLE
INRIA
Equipe Edelweiss (ex Acacia)
priscille.durville@sophia.inria.fr
Tél : 01 39 63 52 77 (Paris - Rocquencourt)
Tél : 04 92 38 50 23 (Sophia Antipolis)
Fax : 04 92 38 77 83
I.N.R.I.A.
Centre de Recherche Sophia Antipolis - Méditerranée
2004 route des Lucioles - B.P. 93
06902 Sophia-Antipolis Cedex
FRANCE
---------------------------------------------
Re: [JAX-RS] pb while passing array as parameter
Posted by Priscille Durville <pr...@sophia.inria.fr>.
Great! :-)
Thanks.
Sergey Beryozkin a écrit :
> Hi,
>
> no problems at all - CXF 2.2.1 should be released very shortly and
> this fix has to be there...
> cheers, Sergey
>
> ----- Original Message ----- From: "Priscille Durville"
> <pr...@sophia.inria.fr>
> To: <us...@cxf.apache.org>
> Sent: Tuesday, April 21, 2009 10:56 AM
> Subject: Re: [JAX-RS] pb while passing array as parameter
>
>
>> Hi!
>> Just a stupid question: is this now included in one of the stable
>> version that can be donwloaded ? (so that I can update my maven pom)
>> cheers,
>> Priscille.
>>
>>
>> Sergey Beryozkin a écrit :
>>> Hi
>>>
>>> I fixed it on Friday evening but could not merge so merged only
>>> today...Arrays can now be supported for all the parameter types
>>> (query, path, header, etc)....There's no need to register a
>>> ParameterHandler for say String[] or Long[], only needed when we
>>> have something like Customer[], on which case a
>>> ParameterHandler<Customer> needed to be registered....
>>>
>>> Can you work with a trunk or do you need a snapshot be deployed ?
>>> You can do a quick local build by follwoing this sequence :
>>> 1. mvn -Pfastinstall
>>> 2. cd api
>>> 3. mvn install (this step is needed because -Pfastinstall in 1.
>>> skips the javadocs creation in api which causes issues in 5.)
>>> 4. cd /distribution
>>> 5. mvn install,
>>>
>>> and get the distribution from a target....
>>>
>>> cheers, Sergey
>>>
>>>
>>> ----- Original Message ----- From: "Priscille Durville"
>>> <pr...@sophia.inria.fr>
>>> To: <us...@cxf.apache.org>
>>> Sent: Friday, March 27, 2009 3:51 PM
>>> Subject: Re: [JAX-RS] pb while passing array as parameter
>>>
>>>
>>>> ok! I understand. :-) Thanks a lot!
>>>> So I will wait for your work :-) because I can't modify the
>>>> signature of my method (from String[] to List<String>) for
>>>> internally reasons.
>>>> Cheers,
>>>> Priscille.
>>>>
>>>>
>>>> Sergey Beryozkin a écrit :
>>>>> Hi
>>>>>
>>>>> If you change it to List<String> then it should work - but I will
>>>>> do some work to ensure arrays are supported too
>>>>> The reason the MessageBodyReader provider is not invoked is that
>>>>> it's not a request body but a parameter orignated from a request uri.
>>>>> That's where ParameterHandler CXF extensions can be used, they
>>>>> have a single fromString() method - but it looks like there's a
>>>>> bug in the runtime in that they can not be matched against Array
>>>>> classes - will fix it too :-)
>>>>>
>>>>> Cheers, Sergey
>>>>>
>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> I have defined (and implemented) the method below :
>>>>>>
>>>>>> @WebMethod
>>>>>> @GET
>>>>>> @Path("/xxx/")
>>>>>> @ConsumeMime({"text/plain", "application/xml", "application/json"})
>>>>>> @ProduceMime({"text/plain", "application/xml", "application/json"})
>>>>>> public String[] getXXX(@QueryParam("index") String[] index);
>>>>>>
>>>>>> My client is an HTML form that contains text inputs with the same
>>>>>> value for the attribute called "name" like this :
>>>>>> <input type="text" name="index" value="toto" />
>>>>>> <input type="text" name="index" value="titi" />
>>>>>> <input type="text" name="index" value="tutu" />
>>>>>>
>>>>>> So the URL is something like this :
>>>>>> ...?index=toto&index=titi&index=tutu
>>>>>>
>>>>>> But it seems that it doesn't work because in this case my method
>>>>>> would have a List<String> parameter instead...
>>>>>> So I have modified my form so that URL send is now like this :
>>>>>> ...?index={"toto", "titi", "tutu"} and I have created a
>>>>>> MessageBodyReader implementation like this :
>>>>>> public class StringArrayTextProvider implements
>>>>>> MessageBodyReader<String[]> { ... }
>>>>>> that I have registered in my beans.xml like that :
>>>>>>
>>>>>> <bean id="StringArrayTextProvider"
>>>>>> class="mypackage.helpers.StringArrayTextProvider"/>
>>>>>> <jaxrs:server id="myService" address="/rest/myservice">
>>>>>> <jaxrs:serviceBeans>
>>>>>> ...
>>>>>> </jaxrs:serviceBeans>
>>>>>> <jaxrs:providers>
>>>>>> <ref bean="StringArrayTextProvider" />
>>>>>> </jaxrs:providers>
>>>>>> </jaxrs:server>
>>>>>> When sending the URL and calling the service, the index
>>>>>> parameter received is null and the method "readFrom" of my
>>>>>> MessageBodyReader is never called. :-(
>>>>>> Where is my mistake?
>>>>>>
>>>>>> Thanks in advance!
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> ---------------------------------------------
>>>>>> Priscille DURVILLE
>>>>>>
>>>>>> INRIA
>>>>>> Equipe Edelweiss (ex Acacia)
>>>>>>
>>>>>> priscille.durville@sophia.inria.fr
>>>>>>
>>>>>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>>>>>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>>>>>> Fax : 04 92 38 77 83
>>>>>>
>>>>>> I.N.R.I.A.
>>>>>> Centre de Recherche Sophia Antipolis - Méditerranée
>>>>>> 2004 route des Lucioles - B.P. 93
>>>>>> 06902 Sophia-Antipolis Cedex
>>>>>> FRANCE
>>>>>> ---------------------------------------------
>>>>>>
>>>>>
>>>>
>>>> --
>>>>
>>>> ---------------------------------------------
>>>> Priscille DURVILLE
>>>>
>>>> INRIA
>>>> Equipe Edelweiss (ex Acacia)
>>>>
>>>> priscille.durville@sophia.inria.fr
>>>>
>>>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>>>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>>>> Fax : 04 92 38 77 83
>>>>
>>>> I.N.R.I.A.
>>>> Centre de Recherche Sophia Antipolis - Méditerranée
>>>> 2004 route des Lucioles - B.P. 93
>>>> 06902 Sophia-Antipolis Cedex
>>>> FRANCE
>>>> ---------------------------------------------
>>>>
>>>
>>
>> --
>>
>> ---------------------------------------------
>> Priscille DURVILLE
>>
>> INRIA
>> Equipe Edelweiss (ex Acacia)
>>
>> priscille.durville@sophia.inria.fr
>>
>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>> Fax : 04 92 38 77 83
>>
>> I.N.R.I.A.
>> Centre de Recherche Sophia Antipolis - Méditerranée
>> 2004 route des Lucioles - B.P. 93
>> 06902 Sophia-Antipolis Cedex
>> FRANCE
>> ---------------------------------------------
>>
>>
>
--
---------------------------------------------
Priscille DURVILLE
INRIA
Equipe Edelweiss (ex Acacia)
priscille.durville@sophia.inria.fr
Tél : 01 39 63 52 77 (Paris - Rocquencourt)
Tél : 04 92 38 50 23 (Sophia Antipolis)
Fax : 04 92 38 77 83
I.N.R.I.A.
Centre de Recherche Sophia Antipolis - Méditerranée
2004 route des Lucioles - B.P. 93
06902 Sophia-Antipolis Cedex
FRANCE
---------------------------------------------
Re: [JAX-RS] pb while passing array as parameter
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,
no problems at all - CXF 2.2.1 should be released very shortly and this fix has to be there...
cheers, Sergey
----- Original Message -----
From: "Priscille Durville" <pr...@sophia.inria.fr>
To: <us...@cxf.apache.org>
Sent: Tuesday, April 21, 2009 10:56 AM
Subject: Re: [JAX-RS] pb while passing array as parameter
> Hi!
> Just a stupid question: is this now included in one of the stable version that can be donwloaded ? (so that I can update my maven
> pom)
> cheers,
> Priscille.
>
>
> Sergey Beryozkin a écrit :
>> Hi
>>
>> I fixed it on Friday evening but could not merge so merged only today...Arrays can now be supported for all the parameter types
>> (query, path, header, etc)....There's no need to register a ParameterHandler for say String[] or Long[], only needed when we have
>> something like Customer[], on which case a ParameterHandler<Customer> needed to be registered....
>>
>> Can you work with a trunk or do you need a snapshot be deployed ?
>> You can do a quick local build by follwoing this sequence :
>> 1. mvn -Pfastinstall
>> 2. cd api
>> 3. mvn install (this step is needed because -Pfastinstall in 1. skips the javadocs creation in api which causes issues in 5.)
>> 4. cd /distribution
>> 5. mvn install,
>>
>> and get the distribution from a target....
>>
>> cheers, Sergey
>>
>>
>> ----- Original Message ----- From: "Priscille Durville" <pr...@sophia.inria.fr>
>> To: <us...@cxf.apache.org>
>> Sent: Friday, March 27, 2009 3:51 PM
>> Subject: Re: [JAX-RS] pb while passing array as parameter
>>
>>
>>> ok! I understand. :-) Thanks a lot!
>>> So I will wait for your work :-) because I can't modify the signature of my method (from String[] to List<String>) for
>>> internally reasons.
>>> Cheers,
>>> Priscille.
>>>
>>>
>>> Sergey Beryozkin a écrit :
>>>> Hi
>>>>
>>>> If you change it to List<String> then it should work - but I will do some work to ensure arrays are supported too
>>>> The reason the MessageBodyReader provider is not invoked is that it's not a request body but a parameter orignated from a
>>>> request uri.
>>>> That's where ParameterHandler CXF extensions can be used, they have a single fromString() method - but it looks like there's a
>>>> bug in the runtime in that they can not be matched against Array classes - will fix it too :-)
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>>> Hi!
>>>>>
>>>>> I have defined (and implemented) the method below :
>>>>>
>>>>> @WebMethod
>>>>> @GET
>>>>> @Path("/xxx/")
>>>>> @ConsumeMime({"text/plain", "application/xml", "application/json"})
>>>>> @ProduceMime({"text/plain", "application/xml", "application/json"})
>>>>> public String[] getXXX(@QueryParam("index") String[] index);
>>>>>
>>>>> My client is an HTML form that contains text inputs with the same value for the attribute called "name" like this :
>>>>> <input type="text" name="index" value="toto" />
>>>>> <input type="text" name="index" value="titi" />
>>>>> <input type="text" name="index" value="tutu" />
>>>>>
>>>>> So the URL is something like this : ...?index=toto&index=titi&index=tutu
>>>>>
>>>>> But it seems that it doesn't work because in this case my method would have a List<String> parameter instead...
>>>>> So I have modified my form so that URL send is now like this : ...?index={"toto", "titi", "tutu"} and I have created a
>>>>> MessageBodyReader implementation like this :
>>>>> public class StringArrayTextProvider implements MessageBodyReader<String[]> { ... }
>>>>> that I have registered in my beans.xml like that :
>>>>>
>>>>> <bean id="StringArrayTextProvider" class="mypackage.helpers.StringArrayTextProvider"/>
>>>>> <jaxrs:server id="myService" address="/rest/myservice">
>>>>> <jaxrs:serviceBeans>
>>>>> ...
>>>>> </jaxrs:serviceBeans>
>>>>> <jaxrs:providers>
>>>>> <ref bean="StringArrayTextProvider" />
>>>>> </jaxrs:providers>
>>>>> </jaxrs:server>
>>>>> When sending the URL and calling the service, the index parameter received is null and the method "readFrom" of my
>>>>> MessageBodyReader is never called. :-(
>>>>> Where is my mistake?
>>>>>
>>>>> Thanks in advance!
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> ---------------------------------------------
>>>>> Priscille DURVILLE
>>>>>
>>>>> INRIA
>>>>> Equipe Edelweiss (ex Acacia)
>>>>>
>>>>> priscille.durville@sophia.inria.fr
>>>>>
>>>>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>>>>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>>>>> Fax : 04 92 38 77 83
>>>>>
>>>>> I.N.R.I.A.
>>>>> Centre de Recherche Sophia Antipolis - Méditerranée
>>>>> 2004 route des Lucioles - B.P. 93
>>>>> 06902 Sophia-Antipolis Cedex
>>>>> FRANCE
>>>>> ---------------------------------------------
>>>>>
>>>>
>>>
>>> --
>>>
>>> ---------------------------------------------
>>> Priscille DURVILLE
>>>
>>> INRIA
>>> Equipe Edelweiss (ex Acacia)
>>>
>>> priscille.durville@sophia.inria.fr
>>>
>>> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
>>> Tél : 04 92 38 50 23 (Sophia Antipolis)
>>> Fax : 04 92 38 77 83
>>>
>>> I.N.R.I.A.
>>> Centre de Recherche Sophia Antipolis - Méditerranée
>>> 2004 route des Lucioles - B.P. 93
>>> 06902 Sophia-Antipolis Cedex
>>> FRANCE
>>> ---------------------------------------------
>>>
>>
>
> --
>
> ---------------------------------------------
> Priscille DURVILLE
>
> INRIA
> Equipe Edelweiss (ex Acacia)
>
> priscille.durville@sophia.inria.fr
>
> Tél : 01 39 63 52 77 (Paris - Rocquencourt)
> Tél : 04 92 38 50 23 (Sophia Antipolis)
> Fax : 04 92 38 77 83
>
> I.N.R.I.A.
> Centre de Recherche Sophia Antipolis - Méditerranée
> 2004 route des Lucioles - B.P. 93
> 06902 Sophia-Antipolis Cedex
> FRANCE
> ---------------------------------------------
>
>