camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sonu123 <sandeepghosh...@rediffmail.com>
Subject Rest to Stax not working
Date Thu, 09 Jun 2016 08:18:11 GMT
Hi,
I have a route which accepts a post request in plain/text format in the REST
DSL, I want to forward it to another route where I intend to parse incoming
body (XML)  using stax component.  My route look like this.

restConfiguration()
.component("servlet")
	.contextPath("Drools-Router/rest")
	.port(9090)
	.enableCORS(true)
	.bindingMode(RestBindingMode.off)

.post().consumes("text/plain")
	.type(String.class)
	.produces("text/plain")
	.outType(String.class) 
	.to("direct:multicastdemo")

from("direct:mainRoute")
.tracing().routeId("stax-parser")
      .log("Content of the body in the main route: ${body}")	
	.to("stax:com.cacib.passer.handler.UserStory1XMLSaxHandler")   
.transform().method("routingService", ,"createRoutingResponse")
.end()

I am getting this exception
/org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 0; Unexpected
EOF in prolog
 at [row,col {unknown-source}]: [1,0]/

When I am changing my first  route to keep XML Payload into  a file  and 
second route read data from the same file, then it is working as expected.  
My modified route, which is working as expected look some like this 

.post().consumes("text/plain")
.type(String.class)
	.produces("text/plain")
	.outType(String.class) 
	.to("file:target/in?fileName=abc-${date:now:yyyyMMdd}.xml")

.from("file:target/in?noop=true&delay=1000")
.tracing().routeId("stax-parser")
      .log("Content of the file in the main route: ${body}")	
	.to("stax:com.cacib.passer.handler.UserStory1XMLSaxHandler")   
	.transform().method("routingService", "createRoutingResponse")
.log("After Drools processing : ${body} ")
.end()
	.log("Done processing a  file: ${body} ");

Can you please tell me where I am doing wrong. 




--
View this message in context: http://camel.465427.n5.nabble.com/Rest-to-Stax-not-working-tp5783748.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message