1. We are trying to invoke REST Service from Camel route, but getting the error: org.apache.cxf.interceptor.Fault: Could not generate the XML stream caused by: com.ctc.wstx.exc.Wstx EOFException: Unexpected EOF in prolog
Our route is like this : <route id="route1"> <from uri="cxf:bean:orderService" /> <to uri="bean:processRequest"/> <to uri="direct:start"/> </route> <route id="route2"> <from uri="direct:start"/> <to uri="http://localhost:8080/cxf-sample-wb-1.0/service1/customerservice/customers"/> <to uri="bean:processResponse"/> <onException> <exception>java.lang.Exception</exception> <handled> <constant>true</constant> </handled> <to uri="log:com.comcast?showAll=true"/> </onException> </route> Code in ProcessRequest.java is : exchange.getIn().setHeader(Exchange.HTTP_METHOD,"POST"); exchange.getIn().setHeader(Exchange.HTTP_QUERY,"id=2"); exchange.getIn().setBody(""); Can someone please advise what is wrong: The similar code in java DSL works fine: ex: public class RouteBuilderExample { public static void main(String args[]) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() { from("direct:start") .setHeader(Exchange.HTTP_QUERY, constant("id=2")) .setHeader(Exchange.HTTP_METHOD,constant("GET")) .to("http://localhost:8080/cxf-sample-wb-1.0/service1/customerservice/customers") .to("direct:end"); //Thread.sleep(10000); // test that our route is working from("direct:end").process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("received resp now: " + exchange.getIn().getBody().getClass()); byte[] b = new byte[100]; InputStream response = (InputStream) exchange.getIn().getBody(); byte[] bytes = exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class, response); String responseText = getResponseString(bytes); System.out.println("response:"+responseText); } private String getResponseString(byte[] data) { StringBuilder sb = new StringBuilder(data.length); for (int i = 0; i <= data.length - 1; i++) { char ch = (char) data[i]; sb.append(ch); } return sb.toString(); } }); } }); context.start(); ProducerTemplate template = context.createProducerTemplate(); template.sendBody("direct:start",""); //Thread.sleep(10000); context.stop(); } } The above code works fine and prints the output from the REST Service, but the equivalent Spring DSL does not. 2. Tried integrating the java DSL with Spring DSL, but facing issue there. It loads the route in java DSL but ignores the Spring DSL: ex: <bean id="centuryServiceRoute" class="com.comcast.oms.poc.route.CenturyRouteBuilder" /> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"> <route id="route1"> <from uri="cxf:bean:orderService" /> <to uri="bean:processRequest"/> <to uri="direct:start"/> </route> <routeBuilder ref="customerServiceRoutes"/> </camelContext> If we change this to : <bean id="centuryServiceRoute" class="com.comcast.oms.poc.route.CenturyRouteBuilder" /> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"> <route id="route1"> <from uri="cxf:bean:orderService" /> <to uri="bean:processRequest"/> <to uri="direct:start"/> </route> <packageScan> <package>com.comcast.oms.poc.route</package> </packageScan> </camelContext> Getting error : ServletContext resource [/WEB-INF/camel-context.xml] is invalid; nested exception is org.xml.sax.SAX ParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'packageScan '. One of '{"http://camel.apache.org/schema/spring":route}' is expected. So there are two issues, firstly cannot invoke REST Service from Spring DSL, secondly cannot integrate java DSL into Spring DSL to do the same. Its little urgent, any idea is appreciated. Thanks, Anirban -- View this message in context: http://camel.465427.n5.nabble.com/Invoking-REST-Service-from-Camel-Spring-DSL-not-working-tp5731911.html Sent from the Camel - Users mailing list archive at Nabble.com.