Is there any simple possibility to produce the list of pojo from jetty:http to cxf-endpoint?
soulaway Jun 10, 2014 7:45 AMHi dear riders!
I need some advices with follows:
From jetty:http I have various requests that will be forwarded to certain cxf endpoints. The aim here is to share the same port between several endpoints.
One of the requests contains the soap xml with list of my pojo (Sms).
I need to deal with pojo, but jetty give me the input stream, and I can convert it only to string (or other stream or byte[]). Is there any possibility to do this simple?
also I have a task to write it as much DSL as camel can.
The routes are:
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent" activation="eager"/>
<bean id="persistenceResponseProcessor" class="ua.np.services.smsinfo.impl.ResponceProcessorImpl"/>
<camel-cxf:cxfEndpoint id="smsCxfEndpoint"
address="{{sms.endpoint.name}}"
serviceClass="ua.np.services.smsinfo.impl.SmsService">
</camel-cxf:cxfEndpoint>
<camelContext id="camel-jetty" xmlns="http://camel.apache.org/schema/blueprint" trace="true">
<route id="jetty-to-cxf">
<from uri="jetty:{{sms.endpoint.address}}:{{sms.endpoint.port}}{{sms.endpoint.name}}?matchOnUriPrefix=true&disableStreamCache=true" /> <!-- retreave the Soap and produce it via InputStream -->
<convertBodyTo type="java.lang.String"/>
<to uri="cxf:bean:smsCxfEndpoint" />
</route>
</camelContext>
<route id="cxf-to-jpa">
<from uri="cxf:bean:smsCxfEndpoint"/> <!-- produce the List of POJO -->
<bean ref="fooProcessor"/>
<setBody>
<simple>
${body[0]}
</simple>
</setBody>
<to uri="jpa://?persistenceUnit=camel-pp"/>
<bean ref="persistenceResponseProcessor"/>
</route>
the stacktrace is:
[ Blueprint Extender: 1] BlueprintCamelContext INFO Route: persistRoute started and consuming from: Endpoint[cxf://bean:smsCxfEndpoint]
[ Blueprint Extender: 1] BlueprintCamelContext INFO Total 1 routes, of which 1 is started.
[ Blueprint Extender: 1] BlueprintCamelContext INFO Apache Camel 2.12.0.redhat-610379 (CamelContext: camel-persister) started in 0.998 seconds
[ qtp1147036174-60] Tracer INFO ID-WSH03626-50312-1402400490641-0-1 >>> (jetty-to-cxf) from(http://0.0.0.0:8090/smsinfo?disableStreamCache=true) --> convertBodyTo[java.lang.String] <<< Pattern:InOut, Headers:{Accept-Encoding=gzip,deflate, Host=localhost:8090, CamelHttpServletRequest=(POST /smsinfo)@1855134803 org.eclipse.jetty.server.Request@6e931c53, CamelHttpCharacterEncoding=UTF-8, Content-Type=text/xml;charset=UTF-8, SOAPAction="", CamelHttpUri=/smsinfo, Connection=keep-alive, CamelHttpMethod=POST, User-Agent=Apache-HttpClient/4.1.1 (java 1.5), CamelHttpUrl=http://localhost:8090/smsinfo, breadcrumbId=ID-WSH03626-50312-1402400490641-0-2, Content-Length=1260, CamelHttpPath=, CamelHttpServletResponse=HTTP/1.1 200
, CamelHttpQuery=null, CamelServletContextPath=/smsinfo}, BodyType:org.eclipse.jetty.server.HttpInput, Body:[Body is instance of java.io.InputStream]
[ qtp1147036174-60] Tracer INFO ID-WSH03626-50312-1402400490641-0-1 >>> (jetty-to-cxf) convertBodyTo[java.lang.String] --> cxf://bean:smsCxfEndpoint <<< Pattern:InOut, Headers:{Content-Length=1260, CamelHttpCharacterEncoding=UTF-8, Content-Type=text/xml;charset=UTF-8, breadcrumbId=ID-WSH03626-50312-1402400490641-0-2, CamelHttpUrl=http://localhost:8090/smsinfo, User-Agent=Apache-HttpClient/4.1.1 (java 1.5), CamelHttpUri=/smsinfo, CamelHttpQuery=null, Host=localhost:8090, CamelHttpMethod=POST, CamelServletContextPath=/smsinfo, CamelHttpPath=, Connection=keep-alive, Accept-Encoding=gzip,deflate, SOAPAction="", CamelHttpServletRequest=(POST /smsinfo)@1855134803 org.eclipse.jetty.server.Request@6e931c53, CamelHttpServletResponse=HTTP/1.1 200
}, BodyType:String, Body:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://impl.smsinfo.services.np.ua/">
<soapenv:Header/>
<soapenv:Body>
<impl:savemessages>
<!--Zero or more repetitions:-->
<messages>
<!--Optional:-->
<id>1</id>
<!--Optional:-->
<bulkId>2</bulkId>
<!--Optional:-->
<groupId>3</groupId>
<!--Optional:-->
<state>4</state>
<!--Optional:-->
<incomingId>5</incomingId>
<!--Optional:-->
<text>6</text>
<!--Optional:-->
<phoneNumber>7</phoneNumber>
</messages>
<messages>
<!--Optional:-->
<id>8</id>
<!--Optional:-->
<bulkId>9</bulkId>
<!--Optional:-->
<groupId>10</groupId>
<!--Optional:-->
<state>11</state>
<!--Optional... [Body clipped after 1000 chars, total length is 1260]
[ qtp1147036174-60] PhaseInterceptorChain WARN Interceptor for {http://impl.smsinfo.services.np.ua/}SmsServiceService#{http://impl.smsinfo.services.np.ua/}savemessages has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: java.lang.String cannot be cast to java.util.List
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:117)[cxf-rt-frontend-jaxws-2.7.0.redhat-610379.jar:2.7.0.redhat-610379]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[cxf-api-2.7.0.redhat-610379.jar:2.7.0.redhat-610379]
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)[cxf-api-2.7.0.redhat-610379.jar:2.7.0.redhat-610379]
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:467)[cxf-api-2.7.0.redhat-610379.jar:2.7.0.redhat-610379]
at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:112)[camel-cxf-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[camel-core-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:151)[camel-jetty-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)[geronimo-servlet_2.5_spec-1.2.jar:1.2]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)[jetty-servlet-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1320)[jetty-servlet-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:119)[jetty-servlets-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:44)[camel-jetty-2.12.0.redhat-610379.jar:2.12.0.redhat-610379]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1291)[jetty-servlet-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:443)[jetty-servlet-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)[jetty-servlet-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.Server.handle(Server.java:367)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)[jetty-http-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)[jetty-http-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)[jetty-server-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)[jetty-io-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)[jetty-io-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)[jetty-util-7.6.9.v20130131.jar:7.6.9.v20130131]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)[jetty-util-7.6.9.v20130131.jar:7.6.9.v20130131]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_51]
Or I should dig thru some other way, for example JaxWs/Rs to Cxf.
Thanks in advance!
Dmitry.