cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: [JAX-RS] pb while passing array as parameter
Date Fri, 27 Mar 2009 15:24:20 GMT
Hi

I'll try to fix it asap....I'll let you know,

cheers, Sergey

----- Original Message ----- 
From: "Priscille Durville" <priscille.durville@sophia.inria.fr>
To: <users@cxf.apache.org>
Sent: Friday, March 27, 2009 2: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
> ---------------------------------------------
> 


Mime
View raw message