Hi Sergey,

Does this mean that MessageBodyReaders are only invoked for JAXWS
annotations?



Sergey Beryozkin-3 wrote:
> 
> Hi
> 
>> 
>> I am trying to convert json data into one for our object types required
>> by a
>> webservice.
>> 
>> I have not started with the json conversion yet, I just wanted the
>> framework
>> in place and ensure that the provider class gets called. But it isn't, so
>> the service just has the parameter 'queryNodeData' set to null.
>> 
>> I can't see what I am doing wrong.
>> 
>> service snippet:
>>    @GET
>>    @Path("search")
>>    @ConsumeMime("application/json")
>>    @ProduceMime("application/json")
>>    public NodeDataMessage search(@QueryParam("querynodedata") final
>> NodeData queryNodeData) {
>>    }
> 
> MessageBodyReades are not invoked for parameters annotated with
> @QueryParam or indeed with other
> JAXRS annotations.
> 
> suppose you GET request looks like this :
> 
> /search?q1=a&q2=b
> 
> If you do not want to do
> 
> public NodeDataMessage search(@QueryParam("q1") String q1,
> @QueryParam("q2") String q2) 
> 
> then you can rely on a CXF extension (note "" as a queryparam value) :
> 
> public NodeDataMessage search((@QueryParam("") final NodeData
> queryNodeData) 
> 
> with NodeData having setQ1 and setQ2 methods 
> 
> Another aproacj is to have UriInfo injected as a context value and access
> query parameters from it
> 
> Cheers, Sergey
> 
>> 
>> beans.xml snippet:
>> <jaxrs:server id="documentServiceRest" address="/rest">
>> <jaxrs:serviceBeans>
>> <ref bean="documentServicesFacadeBean" />
>> </jaxrs:serviceBeans>
>> <jaxrs:providers>
>> <ref bean="nodeDataProviderBean" />
>> </jaxrs:providers>
>> </jaxrs:server>
>> <bean id="nodeDataProviderBean" class="foo.bar.NodeDataProvider" />
>> 
>> provider class:
>>  package foo.bar
>>  import ...
>>  public class NodeDataProvider implements MessageBodyReader<NodeData> {
>>    public boolean isReadable(Class<?> type, Type genericType,
>> Annotation[]
>> annotations) {
>>        return NodeData.class.isAssignableFrom(type);
>>    }
>>    public NodeData readFrom(Class<NodeData> arg0, Type arg1, Annotation[]
>> arg2, MediaType arg3,
>>            MultivaluedMap<String, String> arg4, InputStream arg5) throws
>> IOException,
>>            WebApplicationException {
>>        return new NodeData();
>>    }
>> }
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/MessageBodyReader-implementation-problem-tp20581190p20581190.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
>>
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/MessageBodyReader-implementation-problem-tp20581190p20582576.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to