camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Douglass <douglass.d...@gmail.com>
Subject Re: Rest to Stax not working
Date Thu, 09 Jun 2016 19:51:32 GMT
I suspect the problem is that the body of the message is consumed before it
reaches your stax processor. Specifically, without stream caching, the
following will consume the body if it is any form of InputStream:

.log("Content of the body in the main route: ${body}")

See http://camel.apache.org/stream-caching.html

By changing your routes to write to/read from a file you're effectively
doing your own stream caching.


On Thu, Jun 9, 2016 at 12:20 PM, souciance <souciance.eqdam.rashti@gmail.com
> wrote:

> Maybe I am seeing this wrong but how do these work?
>
> .to("direct:multicastdemo")
>
> from("direct:mainRoute")
>
> The to URI does not match the main from URI
>
> On Thu, Jun 9, 2016 at 10:18 AM, sonu123 [via Camel] <
> ml-node+s465427n5783748h51@n5.nabble.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.
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://camel.465427.n5.nabble.com/Rest-to-Stax-not-working-tp5783748.html
> > To start a new topic under Camel - Users, email
> > ml-node+s465427n465428h31@n5.nabble.com
> > To unsubscribe from Camel - Users, click here
> > <
> http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=
> >
> > .
> > NAML
> > <
> http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Re-Rest-to-Stax-not-working-tp5783806.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message