I think if your route is below, the query "locale=cs_CZ" will be added
to the actual GET request's query string (but not the "reserved"
queries/options as documented in the wiki such as CamelHttpMethod).
from("direct:test").to("restlet:http://localhost:8089?locale=cs_CZ&CamelHttpMethod=GET")
I think if you set custom headers in Camel IN header, they will added to
the request or the form. I *thought* the they get sent as HTTP headers.
Below snippet from
DefaultRestletBinding.populateRestletRequestFromExchange() that performs
the propagation of Camel IN headers to Restlet request.
for (Map.Entry<String, Object> entry :
exchange.getIn().getHeaders().entrySet()) {
if
(!headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(),
entry.getValue(), exchange)) {
// Use forms only for GET and POST/x-www-form-urlencoded
if (request.getMethod() == Method.GET ||
(request.getMethod() == Method.POST && mediaType ==
MediaType.APPLICATION_WWW_FORM)) {
if (entry.getKey().startsWith("org.restlet.")) {
// put the org.restlet headers in attributes
request.getAttributes().put(entry.getKey(),
entry.getValue());
} else {
// put the user stuff in the form
form.add(entry.getKey(),
entry.getValue().toString());
}
} else {
// For non-form post put all the headers in attributes
request.getAttributes().put(entry.getKey(),
entry.getValue());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Populate Restlet request from exchange
header: "
+ entry.getKey() + " value: " +
entry.getValue());
}
}
}
On 03/18/2011 10:18 AM, mat127 wrote:
Hello,
I am using the camel-restlet component to build a REST client calling some
3rd party application RESTful API that is not built upon Camel.
In some cases I need to provide parameters to GET requests like e.g. item id
etc. According to the documentation and the source code I understood that
the restlet component pushes all header fields into the restlet.org request
(using the DefaultRestletBinding class). But I am unable to produce the
desired request this way at all.
Let me explain on following example:
<camel:route>
<camel:from uri="direct:test"/>
<camel:setHeader headerName="locale">
<camel:constant>cs_CZ</camel:constant>
</camel:setHeader>
<camel:to uri="restlet:http://localhost:8089/"/>
...
</camel:route>
Calling this route using following Scala code:
producer.requestBodyAndHeader(
"direct:test", "",
"itemId", id.id,
classOf[java.util.Map[String,Object]]
)
will produce following HTTP request on the localhost:
[pema@dev ~]$ nc -l 8089
GET http://dev:8089/ HTTP/1.1
Host: dev:8089
User-Agent: Noelios-Restlet-Engine/1.1.10
Referer: camel-restlet
Accept: */*
Connection: close
The problem is that the 'locale' and the 'id' parameters are missing there.
How can I get them into the GET request query string? Any hints are welcome!
Regards, Petr
--
View this message in context:
http://camel.465427.n5.nabble.com/restlet-component-GET-request-and-query-string-parameters-tp3964973p3964973.html
Sent from the Camel - Users mailing list archive at Nabble.com.