Hi All,

I am having problems with a restful service that I have developed (CXF 2.2.7). 
I want to pass a List<String> value as a PathParam. I can get this working as a 
QueryParam:

@WebService
@Produces("application/json")
@Consumes("application/json")
public interface RestService {

  @GET
  @Path("/s")
  Response doSomething(@QueryParam("strings") List<String> s);
}

using the (truncated) query: /s?strings=s1&strings=s2

However, I'd like to use a PathParam for this. I have tried:

@GET
@Path("/s/{strings}")
Response doSomething(@PathParam("strings") List<String> s);

And also:

@GET
@Path("/s/{strings:.*}")
Response doSomething(@PathParam("strings") List<String> s);

With the query: /s/s1

Which works fine, but:

With the query: /s/s1;s2

I am still only receive the list [s1] (size 1). I have tried other delimiters 
such as /s/s1+s2 but this results in the list being [s1+s2] (size 1).

Does anyone know what I am doing wrong?

Also, on a related note, how do I get my proxy client to submit the list in the 
correct format for the query? I have a Spring configured service and client 
running inside Jetty in my integration tests:

<bean id="restService" class="x.y.z.service.RestServiceImpl" />

<jaxrs:server id="restfulService" address="http://localhost:9002/";>
  <jaxrs:serviceBeans>
    <ref bean="restService" />
  </jaxrs:serviceBeans>
  <jaxrs:providers>
    <ref bean="listParamHandler" />
  </jaxrs:providers>
</jaxrs:server>

<bean id="restClientFactory" 
class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean">
  <property name="serviceClass" value="x.y.z.service.RestServiceImpl" />
  <property name="address" value="http://localhost:9002/"; />
</bean>

<bean id="restServiceClient" class="x.y.z.service.RestServiceImpl"
  factory-bean="restClientFactory" factory-method="create" />

However, calling:

List<String> strings = new List<String>();
strings.add("s1");
strings.add("s2");
restServiceClient.doSomething(strings);

Results in a call to the server for the URL:

/s/%5Bs1%2C%20s2%5D (/s/[s1, s2])

This is obviously just the result of a List<String>.toString().

So. I have two questions:

1. What is the correct way to submit a String List via a PathParam to a restful 
web service?
2. How can I ensure that my proxy based client conforms to this?

I've looked into registering a ParameterHandler provider on the server side but 
it doesn't seem to be calling it's fromString method.

Thanks very much for your time,


Matt
        

Matthew Glubb
Technical Partner

email: [email protected]
phone: 44 (0) 7715 754017
skype: mglubb

Kite
http://madebykite.com

--
GPG: 96FF DE0E 0B7B 37F0 7F8D C54C E285 3D8F 5625 9244

Reply via email to