You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "chengy@action" <15...@qq.com> on 2013/10/21 13:20:55 UTC

restful service with int array

hi,I publish a restful service with:

@POST
@Path("/removeProcessInstances/{processInstanceIds:.*}")
public void removeProcessInstances(@PathParam("processInstanceIds") int[]
processInstanceIds) throws SDKException {
//remove...
}

but,when i call the service like "xxx/removeProcessInstances/11,22",cxf
handlers "11,22" as string, how to call it? is this right?Thanks



--
View this message in context: http://cxf.547215.n5.nabble.com/restful-service-with-int-array-tp5735335.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: restful service with int array

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 21/10/13 12:20, chengy@action wrote:
> hi,I publish a restful service with:
>
> @POST
> @Path("/removeProcessInstances/{processInstanceIds:.*}")
> public void removeProcessInstances(@PathParam("processInstanceIds") int[]
> processInstanceIds) throws SDKException {
> //remove...
> }
>
> but,when i call the service like "xxx/removeProcessInstances/11,22",cxf
> handlers "11,22" as string, how to call it? is this right?Thanks
>
It took me a bit of time to refresh why it was happening, you can't make 
it work by default, you will need to register JAX-RS 2.0 
ParameterConverter for doing it;

This would if you had something like

"xxx/removeProcessInstances;id=11;id=22"

where 'id' is repeated a number of times, in this case this would be a 
matrix parameter, but when you have "id=1,2" the runtime itself does not 
know how to convert "1,2" into int[] because ',' is a custom separator, 
it can be something else in other cases.

Thus in such cases you need to use custom ParamConverters
HTH
Sergey

>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/restful-service-with-int-array-tp5735335.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>