camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Clarification requested - Camel CXFRS - JAXRS
Date Fri, 27 Nov 2009 15:06:15 GMT
Hi,

 From the stack trace, it looks like the WebClient needs the 
ResourceClass to create the request URL. So I think you need to add the 
serviceClass attribute in the rsClient definition.

Willem
Charles Moulliard wrote:
> Willem,
> 
> I have adapted the flow (between the HTTP requests) and camel route is
> called now. Unfortunately, the calling program receives a HTTP
> response 404 and error is raised in the log
> 
> A. Spring Camel Config
> 
> 	<jaxrs:server id="restService" address="/proxy/"
> staticSubresourceResolution="true">
> 		<jaxrs:serviceBeans>
> 			<ref bean="reportIncidentService"/>
> 		</jaxrs:serviceBeans>
> 	</jaxrs:server>
> 	
> 	
> 	<bean id="reportIncidentService"
> class="org.apache.camel.example.reportincident.restful.ReportIncidentService"/>
> 	<bean id="intercept"
> class="org.apache.camel.example.reportincident.restful.Intercept"/>
> 	
> 	<!-- Camel JAX-RS component called from external calling API/Browser -->
>     <cxf:rsServer id="rsServer"
>                   address="/camel-rest-example/"
> 
> serviceClass="org.apache.camel.example.reportincident.restful.ReportIncidentService"
>     />
> 
>     <!-- Internal camel JAX-RS client who will send feedback to the
> API calling  -->
>     <cxf:rsClient id="rsClient"
>                   address="http://localhost:8181/cxf/proxy/">
>     </cxf:rsClient>
> 
> 	<camel:camelContext trace="true" xmlns="http://camel.apache.org/schema/osgi">
> 
> 		<camel:route>
> 			<camel:from uri="cxfrs:bean:rsServer" />
> 			<camel:to uri="log:org.apache.camel.example.reportIncident?level=DEBUG" />
> 			<camel:to uri="cxfrs:bean:rsClient" />
> 		</camel:route>
> 	</camel:camelContext>
> 
> </beans>
> 
> B. API sends the following requests :
> http://localhost:8181/cxf/camel-rest-example/reportservice/incidents
> 
> CamelHttpMethod=POST,
> CamelHttpCharacterEncoding=UTF-8,
> CamelCxfRsResponseClass=class javax.ws.rs.core.Response,
> CamelAcceptContentType=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,
> Content-Type=application/xml; charset=UTF-8,
> operationName=addIncident,
> CamelHttpPath=/camel-rest-example/reportservice/incidents,
> CamelHttpUri=/cxf/camel-rest-example/reportservice/incidents
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
> 
> C. Error generated :
> 
> 15:27:35,429 | WARN  | 8980685@qtp1-145 | JAXRSInInterceptor
>     | s.interceptor.JAXRSInInterceptor  122 | No root resource
> matching request path /camel-rest-example/reportservice/incidents has
> been found.
> 15:27:35,429 | WARN  | 8980685@qtp1-145 |
> WebApplicationExceptionMapper    | pl.WebApplicationExceptionMapper
> 52 | WebApplicationException has been caught : no cause is available
> 15:27:35,429 | WARN  | 9787361@qtp1-142 | PhaseInterceptorChain
>     | ache.cxf.common.logging.LogUtils  361 | Interceptor has thrown
> exception, unwinding now
> org.apache.cxf.interceptor.Fault: Could not send Message.
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:573)
> 	at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:552)
> 	at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:206)
> 	at org.apache.camel.component.cxf.jaxrs.CxfRsProducer.invokeHttpClient(CxfRsProducer.java:123)
> 	at org.apache.camel.component.cxf.jaxrs.CxfRsProducer.process(CxfRsProducer.java:65)
> 	at org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
> 	at org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:94)
> 	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
> 	at org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
> 	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
> 	at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
> 	at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
> 	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:162)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:223)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:153)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
> 	at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
> 	at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:206)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
> 	at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
> 	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
> 	at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:57)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> 	at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
> 	at org.apache.cxf.transport.http_osgi.OsgiDestination.doMessage(OsgiDestination.java:79)
> 	at org.apache.cxf.transport.http_osgi.OsgiServletController.invokeDestination(OsgiServletController.java:324)
> 	at org.apache.cxf.transport.http_osgi.OsgiServletController.invoke(OsgiServletController.java:112)
> 	at org.apache.cxf.transport.http_osgi.OsgiServlet.invoke(OsgiServlet.java:53)
> 	at org.apache.cxf.transport.http_osgi.SpringOsgiServlet.invoke(SpringOsgiServlet.java:48)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
> 	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
> 	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363)
> 	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:64)
> 	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> 	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
> 	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.handle(HttpServiceContext.java:111)
> 	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:64)
> 	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> 	at org.mortbay.jetty.Server.handle(Server.java:324)
> 	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
> 	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
> 	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:741)
> 	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213)
> 	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
> 	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
> 	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
> Caused by: java.io.IOException: Not Found
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2109)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2057)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1982)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	... 62 more
> 
> 
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
> 
> Apache Camel Group :
> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
> 
> 
> 
> On Thu, Nov 26, 2009 at 2:21 PM, Charles Moulliard <cmoulliard@gmail.com> wrote:
>> My request was send to : http://localhost:8181/cxf/camel-rest-example/
>>
>> Based on your reply, I will adapt my spring camel config.
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>
>> Apache Camel Group :
>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>
>>
>>
>> On Thu, Nov 26, 2009 at 2:15 PM, Willem Jiang <willem.jiang@gmail.com> wrote:
>>> Charles Moulliard wrote:
>>>> Hi,
>>>>
>>>> I would like to better understand how JAXRS works with Camel CXF
>>>> endpoints for RestFull service.
>>>>
>>>> Here is an example :
>>>>
>>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>        xmlns:context="http://www.springframework.org/schema/context"
>>>>        xmlns:camel="http://camel.apache.org/schema/spring"
>>>>        xmlns:cxf="http://camel.apache.org/schema/cxf"
>>>>        xmlns:cxf-core="http://cxf.apache.org/core"
>>>>        xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>>>>        xsi:schemaLocation="
>>>>            http://www.springframework.org/schema/beans
>>>>
>>>>  http://www.springframework.org/schema/beans/spring-beans.xsd
>>>>                http://www.springframework.org/schema/context
>>>>        http://www.springframework.org/schema/context/spring-context.xsd
>>>>                http://camel.apache.org/schema/osgi
>>>>                http://camel.apache.org/schema/osgi/camel-osgi.xsd
>>>>                http://camel.apache.org/schema/spring
>>>>                http://camel.apache.org/schema/spring/camel-spring.xsd
>>>>                http://camel.apache.org/schema/cxf
>>>>                http://camel.apache.org/schema/cxf/camel-cxf.xsd
>>>>                http://cxf.apache.org/jaxrs
>>>>                http://cxf.apache.org/schemas/jaxrs.xsd
>>>>                http://cxf.apache.org/core
>>>>                http://cxf.apache.org/schemas/core.xsd">
>>>>
>>>>        <import resource="classpath:META-INF/cxf/cxf.xml" />
>>>>        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"
/>
>>>>        <import resource="classpath:META-INF/cxf/cxf-extension-http.xml"
/>
>>>>        <import
>>>> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>>>>        <import
>>>> resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
>>>>
>>>>        <jaxrs:server id="restService" address="/camel-rest-example/"
>>>> staticSubresourceResolution="true">
>>>>                <jaxrs:serviceBeans>
>>>>                        <ref bean="reportIncidentService"/>
>>>>                </jaxrs:serviceBeans>
>>>>                <jaxrs:features>
>>>>                <cxf-core:logging/>
>>>>                </jaxrs:features>
>>>>        </jaxrs:server>
>>>>
>>>>        <bean id="reportIncidentService"
>>>>
>>>> class="org.apache.camel.example.reportincident.restful.ReportIncidentService"/>
>>>>
>>>>    <cxf:rsServer id="rsServer"
>>>>                  address="/proxy/"
>>>>
>>>>
>>>> serviceClass="org.apache.camel.example.reportincident.restful.ReportIncidentService"
>>>>    />
>>>>
>>>>    <cxf:rsClient id="rsClient"
>>>>                  address="http://localhost:8181/cxf/camel-rest-example/"
>>>>
>>>>
>>>> serviceClass="org.apache.camel.example.reportincident.restful.ReportIncidentService">
>>>>    </cxf:rsClient>
>>>>
>>>>        <camel:camelContext trace="true"
>>>> xmlns="http://camel.apache.org/schema/osgi">
>>>>
>>>>                <camel:route>
>>>>                        <camel:from uri="cxfrs:bean:rsServer" />
>>>>                        <camel:to uri="cxfrs:bean:rsClient" />
>>>>                </camel:route>
>>>>        </camel:camelContext>
>>>>
>>>> </beans>
>>>>
>>>>
>>>> Can we explain/describe the process like this ?
>>>>
>>>> API sending HTTP REST (get/post/put/delete) request --> jetty web
>>>> server running OSGI CXF servlet receives the call --> which is
>>>> propagated to jaxrs:server component --> request is parsed and send to
>>>> the service ReportIncidentService (where REST services are defined
>>>> using annotations) --> next an object is send to the Camel
>>>> cxfrs:rsServer endpoint who will next propagate the payload into camel
>>>> route --> camel route --> arrives at cxf:RsClient (which send back
the
>>>> result to JAXRS:server) --> reply to API calling ?
>>> I'm confused, can you tell me the address that API sending HTTP request?
>>>
>>> If you send the request to http://localhost:8181/cxf/camel-rest-example/,
>>> the jaxrs:server component will be invoked, there is no further camel route
>>> involved.
>>> If you send the request to http://localhost:8181/cxf/proxy the cxf:rsServer
>>> will parser the request (like the camel-cxf consumer will turn a SOAP
>>> request to POJO method invocation) redirect the request to cxf:rsClient, the
>>> cxf:rsClient will invoke the service of Jaxrs:server, then put the response
>>> back to cxf:rsServer.
>>>
>>>> Questions :
>>>>
>>>> 1) Why do we have to declare serviceClass in cxfrs:rsServer endpoint
>>>> as it will propagate body/payload to camel route ?
>>> For the cxf:rsClient, CXF RS support two types client API, one is Proxy API,
>>> you need to specify the service class for it ; the other is HttpAPI, it just
>>> like camel-http component.
>>>> 2) Why both jaxrs:server and cxfrs:rsClient uses the same class reference
>>>> ?
>>> You can specify different service class for them , but you need do operation
>>> and parameter mapping yourself.
>>>> 3) Can we have two different classes : one extracting the info
>>>> received from HTTP request, putting them in a message propagated
>>>> though queues / camel process to a service component who will answer
>>>> and the response will be send back by cxf:rsClient to the API calling
>>>> the web service ? How to design this ?
>>> How about you use two jms queue for the keeping the request and response ?
>>>
>>> from("cxfrs:bean:rsServer").to("jms:queue:request").
>>>        to("cxfrs:bean:rsClient").to("jms:queue:response").
>>>
>>>
>>>>
>>>> Regards,
>>>>
>>>> Charles Moulliard
>>>> Senior Enterprise Architect
>>>> Apache Camel Committer
>>>>
>>>> *****************************
>>>> blog : http://cmoulliard.blogspot.com
>>>> twitter : http://twitter.com/cmoulliard
>>>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>>>
>>>> Apache Camel Group :
>>>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>>>
>>> Willem
>>>
> 



Mime
View raw message