camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Rossi" <>
Subject REST web service - multiple parametes
Date Sun, 01 May 2011 15:35:04 GMT
Hi all, 
I'm creating a RESTful web service, but I don't understand how to manage multiple parameters
in the exchange message. My idea is that if multiple parameters are passed to the service,
I can find some sort of hashmap, indexed by parameter name, in the body of the message created
by the REST endpoint, but this doesn't happen.
Reading from the source code, method org.apache.camel.component.cxf.jaxrs.DefaultCxfRsBinding.populateExchangeFromCxfRsRequest(...),
I see that a "Object[] paramArray" (that has only parameters values and not names) is saved
in the message body with "camelMessage.setBody(new MessageContentsList(paramArray))".

Am I missing something or multiple parameters are really passed as *positional* parameter
of an Object[] array?
I'm using Camel 2.7.1 with the following definition (I've pasted only the relevant portion)

public class DocumentListRest  {

  public Document getDocument(@PathParam("userId") long userId, @PathParam("documentId")
long documentId) {
    return null;  // Is it ok if I return null?

my Spring configuration is:


<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />

<cxf:rsServer id="rsServer" address="/" serviceClass="xxx.yyy.impl.DocumentListRest" />

<camelContext id="camel" trace="true" xmlns="">
    <from uri="cxfrs:bean:rsServer" />
        <simple>${in.header.operationName} == 'getDocument'</simple>

Tracing gave me the follwing output:

(route1) from(cxfrs://bean:rsServer) --> choice <<< Pattern:InOut, Headers:{CamelAcceptContentType=*/*,
Content-Type=null, Accept=*/*, CamelHttpUri=/server/document/23/234, CamelHttpMethod=GET,
connection=Keep-Alive, CamelCxfRsResponseClass=class xxx.yyy.bean.Document, CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@3b48a8e6],
CamelHttpPath=document/23/234, user-agent=Wget/1.12 (linux-gnu), operationName=getDocument,
CamelCxfRsResponseGenericType=class xxx.yyy.bean.Document, host=localhost:8080}, BodyType:org.apache.cxf.message.MessageContentsList,


View raw message