camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Kampf <joseph.ka...@gmail.com>
Subject Re: Rest to Stax not working
Date Fri, 10 Jun 2016 19:39:32 GMT
I had a similar problem recently with JaxRS component.

The output of the JaxRS was an instance of javax.ws.rs.core.Response.

I needed to pull the Entity out of the response and set that to my Body before doing an XML
parse.

Here is the snippet I had:

Response jaxrsResponse = newExchange.getIn().getBody(Response.class);
if (jaxrsResponse != null)
	newExchange.getIn().setBody(jaxrsResponse.getEntity());

					                                                return newExchange;






On 6/9/16, 4:18 AM, "sonu123" <sandeepghosh_73@rediffmail.com> wrote:

>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