Hi, I have created servlet which will return a JSON object. I am trying to
connect the servlet using Camel and put it in a buffer. But my servlet
didn't invoked at all and not throwing any error. I am currently in the
beginning stage on using camel. 

Please help.

I have used the following code.

package com.test.camel;

import java.io.IOException;
import java.io.OutputStream;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;

public class TestRouteBuilder extends RouteBuilder {

        @Override
        public void configure() throws Exception {

                
from("servlet:localhost:9078/ThirdPartyApplication/MaintainCases")
                                .setHeader("stream", constant(mystream))
                                .process(new Processor() {
                                        public void process(Exchange exchange) 
throws Exception {
                                                String contentType = 
exchange.getIn().getHeader(
                                                                
Exchange.CONTENT_TYPE, String.class);
                                                String path = 
exchange.getIn().getHeader(
                                                                
Exchange.HTTP_URI, String.class);
                                                path = 
path.substring(path.lastIndexOf("/"));

                                                
exchange.getOut().setHeader(Exchange.CONTENT_TYPE,
                                                                contentType + 
"; charset=UTF-8");
                                                
exchange.getOut().setHeader("PATH", path);
                                                
exchange.getOut().setBody("*Hello World*");
                                        }
                                }).to("stream:header");

                
        }

        private OutputStream mystream = new MyOutputStream();
        private StringBuilder sb = new StringBuilder();

        private class MyOutputStream extends OutputStream {

                public void write(int b) throws IOException {
                        sb.append((char) b);
                }
        }

}



--
View this message in context: 
http://camel.465427.n5.nabble.com/Need-input-on-accessing-http-servlet-tp5787954.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to