You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dfgcamel <df...@gmail.com> on 2015/08/06 23:34:24 UTC

redirecting with jetty component

Hi,

I could use some direction in getting something like the following to work. 
I've gotten the first part to work where I create and new user and determine
parameters for the next request.  This is where I'm stuck.  I basically want
to login to the same application where I've just created a new user and land
on the default page for that user.  I know the format for doing the login,
but I've been unable to redirect to the login page without errors.  See the
errors at the end of the code sample.  Also, Just to see if I could get it
to redirect, I used a public site for this test.

Any suggestions or ideas greatly appreciated....

Dennis....


public class JettyRouteBuilder extends RouteBuilder {
	public void configure() {
		from("jetty:http://localhost:8181/samplehttpservice")
		.process(/*
                               * eternal process to create and account in a
third party application and retrieve
                               * parameters (param1 and param2) for next
request
                               */
                              )
		.to("http://www.xxx.com:8080/login?param1=value1&param2=value2");
	}
}


org.apache.camel.component.http.HttpOperationFailedException: HTTP operation
failed invoking http://www.google.com/ with statusCode: 405
	at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:230)
	at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:156)
	at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
	at
org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:162)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
	at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496)
	at
org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:136)




--
View this message in context: http://camel.465427.n5.nabble.com/redirecting-with-jetty-component-tp5770397.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: redirecting with jetty component

Posted by dfgcamel <df...@gmail.com>.
Thanks:

That worked perfectly!!

Dennis...



--
View this message in context: http://camel.465427.n5.nabble.com/redirecting-with-jetty-component-tp5770397p5770636.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: redirecting with jetty component

Posted by Shing Hing Man <ma...@yahoo.com.INVALID>.
Hi,
Have you tried adding the redirect URL in the Exchange.Out ?
Below is an example to redirect to http://uk.some.com .

 context.addRoutes(new RouteBuilder() { @Override public void configure() {  from("jetty:http4://localhost:8081/foo?matchOnUriPrefix=true") .process(new Processor() {
 public void process(Exchange exchange) throws Exception {
 Message messageIn = exchange.getIn(); HttpServletRequest request = messageIn.getBody(HttpServletRequest.class); String label=request.getParameter("label"); String labelModified = label + "Modified";  exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 302);
 exchange.getOut().setHeader("location", "http://uk.some.com?name=" + labelModified);
 }
 }); 
 }
 });
Shing
 


     On Friday, 7 August 2015, 9:10, dfgcamel <df...@gmail.com> wrote:
   

 Hi,

I could use some direction in getting something like the following to work. 
I've gotten the first part to work where I create and new user and determine
parameters for the next request.  This is where I'm stuck.  I basically want
to login to the same application where I've just created a new user and land
on the default page for that user.  I know the format for doing the login,
but I've been unable to redirect to the login page without errors.  See the
errors at the end of the code sample.  Also, Just to see if I could get it
to redirect, I used a public site for this test.

Any suggestions or ideas greatly appreciated....

Dennis....


public class JettyRouteBuilder extends RouteBuilder {
    public void configure() {
        from("jetty:http://localhost:8181/samplehttpservice")
        .process(/*
                              * eternal process to create and account in a
third party application and retrieve
                              * parameters (param1 and param2) for next
request
                              */
                              )
        .to("http://www.xxx.com:8080/login?param1=value1¶m2=value2");
    }
}


org.apache.camel.component.http.HttpOperationFailedException: HTTP operation
failed invoking http://www.google.com/ with statusCode: 405
    at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:230)
    at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:156)
    at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
    at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
    at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
    at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at
org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:162)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
    at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496)
    at
org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:136)




--
View this message in context: http://camel.465427.n5.nabble.com/redirecting-with-jetty-component-tp5770397.html
Sent from the Camel - Users mailing list archive at Nabble.com.