You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Pranab Mehta <ro...@gmail.com> on 2013/01/23 22:10:22 UTC
Get full request url from Exchange
I am running Camel 2.8, and to proxy a https web service I use the
following route:
from("servlet:///proxyWebService/api/?matchOnUriPrefix=true")
.process(myProcessor)
.to("https4://realWebService:8443/api/?bridgeEndpoint=true&throwExceptionOnFailure=false");
Now, in the process leg, I want to be able to extract the full Request
URL with hostname and port that was used to access the servlet. I am
hoping this information is somewhere in the Exchange, but I am unable
to find it.
tia,
rouble
Re: Get full request url from Exchange
Posted by chandler <pe...@sandia.gov>.
The below seems to work.
--
View this message in context: http://camel.465427.n5.nabble.com/Get-full-request-url-from-Exchange-tp5726086p5793026.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Get full request url from Exchange
Posted by rouble <r....@gmail.com>.
This is exactly what I need, but the exchange does not seem to have
HttpMessage within it. I tried both versions of HttpMessage (http and
http4) that camel supports. Here is my code:
//import org.apache.camel.component.http4.HttpMessage;
import org.apache.camel.component.http.HttpMessage;
HttpMessage msg = exchange.getIn(HttpMessage.class); //msg is
always null
HttpServletRequest req = msg.getRequest();
Note, my routebuilder code looks something like this:
from("servlet:///proxyWebService/api/?matchOnUriPrefix=true")
.process(myProcessor)
.to("https4://realWebService:8443/api/?bridgeEndpoint=true&throwExceptionOnFailure=false");
So, the request is coming in from a servlet context.
tia,
rouble
On Thu, Jan 24, 2013 at 3:32 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, Jan 23, 2013 at 10:10 PM, Pranab Mehta <ro...@gmail.com> wrote:
>> I am running Camel 2.8, and to proxy a https web service I use the
>> following route:
>> from("servlet:///proxyWebService/api/?matchOnUriPrefix=true")
>> .process(myProcessor)
>> .to("https4://realWebService:8443/api/?bridgeEndpoint=true&throwExceptionOnFailure=false");
>>
>> Now, in the process leg, I want to be able to extract the full Request
>> URL with hostname and port that was used to access the servlet. I am
>> hoping this information is somewhere in the Exchange, but I am unable
>> to find it.
>>
>
> You can get access to the HttpServletRequest, where you can find all
> the details you need.
>
> In the processor you can do
>
> HttpMessage msg = exchange.getIn(HttpMessage.class);
> HttpServletRequest req = msg.getRequest();
>
>
>> tia,
>> rouble
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
Re: Get full request url from Exchange
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jan 23, 2013 at 10:10 PM, Pranab Mehta <ro...@gmail.com> wrote:
> I am running Camel 2.8, and to proxy a https web service I use the
> following route:
> from("servlet:///proxyWebService/api/?matchOnUriPrefix=true")
> .process(myProcessor)
> .to("https4://realWebService:8443/api/?bridgeEndpoint=true&throwExceptionOnFailure=false");
>
> Now, in the process leg, I want to be able to extract the full Request
> URL with hostname and port that was used to access the servlet. I am
> hoping this information is somewhere in the Exchange, but I am unable
> to find it.
>
You can get access to the HttpServletRequest, where you can find all
the details you need.
In the processor you can do
HttpMessage msg = exchange.getIn(HttpMessage.class);
HttpServletRequest req = msg.getRequest();
> tia,
> rouble
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen