You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by indrayani <in...@gmail.com> on 2013/05/31 11:54:13 UTC

regarding status code 302

Hi All,
I have defined a following route in my camel config xml

<route>
    
    <from uri="servlet:///hello"/>
    <to uri="http://localhost:8085/testagent?bridgeEndpoint=true" />
</route>

I am sending a request through following code from a web application :

String servletURL
="http://localhost:8085/camel-example-servlet-tomcat-no-spring-2.11.0/camel/hello?name=test123";

HttpClient client = new DefaultHttpClient();  
HttpPost post = new HttpPost(servletURL); 
HttpResponse response = client.execute(post, context);

when i execute this code , I am getting following error

 caught: org.apache.camel.component.http.HttpOperationFailedException: HTTP
operation failed invoking http://localhost:8085/erpagent?name=test123 with
statusCode: 302


I chcked on forum regarding this error and what I understood is , we need to
login to URL first.
but this url "http://localhost:8085/testagent?bridgeEndpoint=true"  is just
a simple servlet and there is no login required.

So, how should I resolve this issue now, basically , I am not able to
understanding why am I getting this exception.


	



--
View this message in context: http://camel.465427.n5.nabble.com/regarding-status-code-302-tp5733545.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: regarding status code 302

Posted by indrayani <in...@gmail.com>.
Hi,
i have some different requirement, i am not able to understand how to
proceed with that,
can anyone tell me some bullet points to start with the same, the scenario
is as follows :

1.there is one web application A deployed on tomcat
2.there is another web application B deployed on jetty on different machine
3.there should be a camel web application deployed on tomcat on different
machine
4.now , the scenario is, A should be able to send a message to camel
application ,and camel application should  get the message and calls
application B .
5. application B should send a response back to camel application and camel
application should send this response back to the caller application A.

so, here, I am not able to understand
1. how should i send a request from A, like what code do i need to add
2.how should i configure the route in camel application, do i need to use
ActiveMQ for this?
3. how the application B will get a call from camel application and sends a
response back to camel 

I just need some clues in order to proceed.


Thanks in advance





--
View this message in context: http://camel.465427.n5.nabble.com/regarding-status-code-302-tp5733545p5733706.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: regarding status code 302

Posted by Claus Ibsen <cl...@gmail.com>.
You can try with adding this option
httpClient.followRedirects=true

to the http endpoint uri

Then it could possible do the redirect handling itself. But you can
google the internet about http client 3.x and how to deal with
redirects.

On Fri, May 31, 2013 at 12:33 PM, indrayani <in...@gmail.com> wrote:
> Hi,
> thank you so much for the quick reply.
> after adding throwExceptionOnFailure=false , I am not getting any exception
> now.
> but the url that i have mentioned in To,  i think that is not getting the
> request.
>
> also,
> in the reply you have mentioned :
>
> " your client should then call again with the redirected url.
> The redirect url should be returned in the http headers "
>
> can you please explain me how should i do that
>
>
> Regards,
> Indrayani
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/regarding-status-code-302-tp5733545p5733547.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

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: regarding status code 302

Posted by indrayani <in...@gmail.com>.
Hi, 
thank you so much for the quick reply.
after adding throwExceptionOnFailure=false , I am not getting any exception
now.
but the url that i have mentioned in To,  i think that is not getting the
request.

also, 
in the reply you have mentioned :

" your client should then call again with the redirected url. 
The redirect url should be returned in the http headers "

can you please explain me how should i do that


Regards,
Indrayani




--
View this message in context: http://camel.465427.n5.nabble.com/regarding-status-code-302-tp5733545p5733547.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: regarding status code 302

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this page
http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html

You need to set throwExceptionOnFailure=false

And error code 3xx is redirect error codes. So your client should then
call again with the redirected url.
The redirect url should be returned in the http headers


On Fri, May 31, 2013 at 11:54 AM, indrayani <in...@gmail.com> wrote:
> Hi All,
> I have defined a following route in my camel config xml
>
> <route>
>
>     <from uri="servlet:///hello"/>
>     <to uri="http://localhost:8085/testagent?bridgeEndpoint=true" />
> </route>
>
> I am sending a request through following code from a web application :
>
> String servletURL
> ="http://localhost:8085/camel-example-servlet-tomcat-no-spring-2.11.0/camel/hello?name=test123";
>
> HttpClient client = new DefaultHttpClient();
> HttpPost post = new HttpPost(servletURL);
> HttpResponse response = client.execute(post, context);
>
> when i execute this code , I am getting following error
>
>  caught: org.apache.camel.component.http.HttpOperationFailedException: HTTP
> operation failed invoking http://localhost:8085/erpagent?name=test123 with
> statusCode: 302
>
>
> I chcked on forum regarding this error and what I understood is , we need to
> login to URL first.
> but this url "http://localhost:8085/testagent?bridgeEndpoint=true"  is just
> a simple servlet and there is no login required.
>
> So, how should I resolve this issue now, basically , I am not able to
> understanding why am I getting this exception.
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/regarding-status-code-302-tp5733545.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

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