You don't need to code a servlet yourself, you just declare to consume from the camel servlet like this:
<from uri="servlet:///path"/> After the from you do whatever processing you need, keeping in mind that camel maps the http request headers to the exchange.in.headers and the http body to exchange.in.body Read the camel servlet component docs for more details and examples. Mirko Il giorno 12/ott/2011, alle ore 22:23, AnitaJ <javasp...@gmail.com> ha scritto: > Hi everyone, > > I am working with a camel example application. I have a web.xml file with a > mapping for CamelHttpTransportServlet. When I attached the source code to > the camelservlet, I see that the application exits with a 404 because it > could not find a HTTPConsumer. Do I need to create a HTTPConsumer explicitly > (if so, would that be in the context.xml?) ?? I must be missing something > real basic, but I have spent so much time on this and I am just about ready > to tear my hair out by the roots! If any of you can point me in the right > direction, that would be so great!!! > > Thanks!! > > CamelServlet > > > protected void service(.. > .. > HttpConsumer consumer = resolve(request); > if (consumer == null) { > log.debug("No consumer to service request {}", request); > response.sendError(HttpServletResponse.SC_NOT_FOUND); > return; > } > .. > } > > protected HttpConsumer resolve(HttpServletRequest request) { > String path = request.getPathInfo(); > if (path == null) { > return null; > } > HttpConsumer answer = consumers.get(path); > > if (answer == null) { > for (String key : consumers.keySet()) { > if (consumers.get(key).getEndpoint().isMatchOnUriPrefix() && > path.startsWith(key)) { > answer = consumers.get(key); > break; > } > } > } > return answer; // this is null > } > > web.xml > > <servlet> > <servlet-name>CamelServlet</servlet-name> > > <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class> > <init-param> > <param-name>contextConfigLocation</param-name> > <param-value>context.xml</param-value> > </init-param> > </servlet> > > <servlet-mapping> > <servlet-name>CamelServlet</servlet-name> > <url-pattern>/camel/*</url-pattern> > </servlet-mapping> > > context.xml > > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:camel="http://camel.apache.org/schema/spring" > xsi:schemaLocation=" > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd"> > > <camel:camelContext id="camelContext"> > <camel:jmxAgent id="agent" disabled="true"/> > <camel:routeBuilder ref="tutorialRouteBuilder"/> > </camel:camelContext> > > <bean id="tutorialRouteBuilder" > class="org.apache.camel.example.gae.TutorialRouteBuilder"/> > > </beans> > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Newbie-question-tp4896854p4896854.html > Sent from the Camel - Users mailing list archive at Nabble.com.