Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 53255 invoked from network); 11 Apr 2010 08:18:03 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Apr 2010 08:18:03 -0000 Received: (qmail 44922 invoked by uid 500); 11 Apr 2010 08:18:02 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 44738 invoked by uid 500); 11 Apr 2010 08:18:02 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 44729 invoked by uid 99); 11 Apr 2010 08:18:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 08:18:01 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_HELO_PASS,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 08:17:56 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1O0sMI-0008HH-Vi for users@camel.apache.org; Sun, 11 Apr 2010 01:17:34 -0700 Message-ID: <28207107.post@talk.nabble.com> Date: Sun, 11 Apr 2010 01:17:34 -0700 (PDT) From: jejmaster To: users@camel.apache.org Subject: Re: Null parameters when routing CXFRS endpoints In-Reply-To: <4BC1618A.7080104@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: jejmaster@gmail.com References: <28186748.post@talk.nabble.com> <4BBE9DFB.5040508@gmail.com> <28187620.post@talk.nabble.com> <28189696.post@talk.nabble.com> <4BBEF62B.30503@gmail.com> <28190020.post@talk.nabble.com> <4BBEFC70.7000606@gmail.com> <28191256.post@talk.nabble.com> <4BC07A8A.2010000@gmail.com> <28202521.post@talk.nabble.com> <4BC1618A.7080104@gmail.com> I think you can't have more than 1 resource class to create a right proxy as i have investigated the code and CxfRsEndpoint only sets the first resourceClasss upon setting up of JAXRSClientFactoryBean Here: protected void setupJAXRSClientFactoryBean(JAXRSClientFactoryBean cfb) { // address cfb.setAddress(getEndpointUri()); if (getResourceClasses() != null) { cfb.setResourceClass(getResourceClasses().get(0)); } } This will affect on the reflection part in invokeProxyClient: Method method = findRightMethod(sfb.getResourceClasses(), methodName, getParameterTypes(parameters)); It will only get 1 resource class to get the right method. Jejo willem.jiang wrote: > > I don't think current Spring DSL support to set the Object[] into > header. I'm afraid you need to use processor or Java DSL to do this job. > > Willem > > jejmaster wrote: >> Hi Willem, >> >> Thats another good feature. But how do you set the Object[] varValues on >> CxfConstants.CAMEL_CXF_RS_VAR_VALUES message header via spring xml? >> >> >> >> >> >> >> ? >> >> >> >> Or do I still need to create a processor bean class to manually set this? >> >> Regards, >> Jejo >> >> >> >> willem.jiang wrote: >>> Oh. my mistake. >>> If you take a look at the CxfRsProducer.invokeProxyClient(Exchange >>> exchange), you will find you need to set >>> CxfConstants.CAMEL_CXF_RS_VAR_VALUES message header to set the varValues >>> if there are more than one resource class to create a right proxy. >>> >>> Willem >>> >>> jejmaster wrote: >>>> I see. That's great. So you mean the serviceClass parameter is optional >>>> when >>>> configuring cxf? How do you expose the service without specifying the >>>> serviceClass ? Isn't it required configuring at least the cxf:rsServer? >>>> >>>> >>> serviceClass="com.project.service.impl.ServiceManagerImpl" /> >>>> >>>> >>> address="http://localhost:8080/services/rest" >>>> serviceClass="com.project.service.impl.ServiceManagerImpl" /> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> Jejo >>>> >>>> >>>> willem.jiang wrote: >>>>> It's hard to create the Proxy without specify the ResourceClass. >>>>> HttpClient API is more friendly, as you don't need to specify the >>>>> ResourceClass when creating the client. >>>>> >>>>> Willem >>>>> >>>>> jejmaster wrote: >>>>>> Hi Willem, >>>>>> >>>>>> Its working enough in 2.3-SNAPSHOT. but we decided to use 2.2 as of >>>>>> the >>>>>> moment until 2.3 gets released. >>>>>> >>>>>> Do you recommend on the httpclient rather than the proxyClient? >>>>>> >>>>>> Jejo >>>>>> >>>>>> >>>>>> >>>>>> willem.jiang wrote: >>>>>>> Hi Jejo >>>>>>> >>>>>>> Please feel free to log a JIRA for it, doesn't the HttpClient work >>>>>>> good >>>>>>> for you ? >>>>>>> >>>>>>> Willem >>>>>>> >>>>>>> jejmaster wrote: >>>>>>>> I found out that JAXRS Client only sends 1 parameter. So i will >>>>>>>> just >>>>>>>> have >>>>>>>> to >>>>>>>> configure my service class to only accept 1 parameter instead of >>>>>>>> two. >>>>>>>> Ill >>>>>>>> just wrap it in a transfer object. >>>>>>>> >>>>>>>> Anyway, maybe as a enhancement to camel-cxf jaxrs, hopefully we can >>>>>>>> also >>>>>>>> use >>>>>>>> and support different rest clients such as Httpclient and URLStream >>>>>>>> so >>>>>>>> form >>>>>>>> parameters can also be allowed. >>>>>>>> >>>>>>>> Regards, >>>>>>>> Jejo >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> jejmaster wrote: >>>>>>>>> Hi Willem, >>>>>>>>> >>>>>>>>> I just used the TestProcessor to see the value of the >>>>>>>>> inMessage.getBody() >>>>>>>>> because even if there's no processor, the parameters really gets >>>>>>>>> null >>>>>>>>> when >>>>>>>>> routed. >>>>>>>>> >>>>>>>>> I am digging the code right now at CxfRSProducer. And it seems >>>>>>>>> that >>>>>>>>> the >>>>>>>>> problem is in the Reflection part in the method invokeProxyClient. >>>>>>>>> >>>>>>>>> Object response = method.invoke(target, parameters); >>>>>>>>> >>>>>>>>> i have logged the parameters before this part and the values were >>>>>>>>> still >>>>>>>>> in >>>>>>>>> there. >>>>>>>>> >>>>>>>>> I have also tried updating how JAXRSClientFactoryBean (cfb) is >>>>>>>>> used >>>>>>>>> as >>>>>>>>> a >>>>>>>>> jaxrs client. >>>>>>>>> >>>>>>>>> Example: >>>>>>>>> >>>>>>>>> BindingFactoryManager manager = >>>>>>>>> cfb.getBus().getExtension(BindingFactoryManager.class); >>>>>>>>> JAXRSBindingFactory factory = new JAXRSBindingFactory(); >>>>>>>>> factory.setBus(cfb.getBus()); >>>>>>>>> manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, >>>>>>>>> factory); >>>>>>>>> Object targetClass = cfb.create(sfb.getResourceClasses().get(0)); >>>>>>>>> >>>>>>>>> Object response = method.invoke(targetClass , parameters); >>>>>>>>> >>>>>>>>> >>>>>>>>> Still, the parameters, gets null after this method.invoke(..) >>>>>>>>> reflection. >>>>>>>>> >>>>>>>>> >>>>>>>>> Im still digging on it and checking if i could replicate the >>>>>>>>> reflection >>>>>>>>> part. Can you also analyze/replicate it? >>>>>>>>> >>>>>>>>> Thanks. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> willem.jiang wrote: >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> Can I see the code that you do in the testProcessor? >>>>>>>>>> If you don't set the exchange.outMessage(), you should get the >>>>>>>>>> right >>>>>>>>>> parameter from the inMessage body. >>>>>>>>>> >>>>>>>>>> Willem >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> jejmaster wrote: >>>>>>>>>>> Hello, >>>>>>>>>>> >>>>>>>>>>> I am using the Camel 2.3-SNAPSHOT and implementing the CXFRS >>>>>>>>>>> routing >>>>>>>>>>> through >>>>>>>>>>> ProxyClient. I have setup my JAXRS Service Class method to >>>>>>>>>>> accept >>>>>>>>>>> 2 >>>>>>>>>>> parameters, a String and an Object. The service is working fine >>>>>>>>>>> when >>>>>>>>>>> i >>>>>>>>>>> am >>>>>>>>>>> invoking it directly but when i am using the cxfrs camel >>>>>>>>>>> routing, >>>>>>>>>>> these >>>>>>>>>>> 2 >>>>>>>>>>> parameters are having null values. Anyway here's my setup: >>>>>>>>>>> >>>>>>>>>>> My Service/Resource Class: >>>>>>>>>>> >>>>>>>>>>> @Path("/myservice") >>>>>>>>>>> Class MyService{ >>>>>>>>>>> >>>>>>>>>>> @POST >>>>>>>>>>> @Path("/myMethod") >>>>>>>>>>> public ModelCollectionTO getPatients(@FormParam("loc") String >>>>>>>>>>> location, >>>>>>>>>>> @FormParam("") ModelTO modelTO){ >>>>>>>>>>> log.debug(location); >>>>>>>>>>> log.debug(modelTO); >>>>>>>>>>> .... >>>>>>>>>>> } >>>>>>>>>>> } >>>>>>>>>>> >>>>>>>>>>> Router Definition: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> I tried to use a test processor to capture the exchange and the >>>>>>>>>>> inMessage. >>>>>>>>>>> The 2 parameters are correct. with values: >>>>>>>>>>> >>>>>>>>>>> location: "String"; >>>>>>>>>>> ModelTO: firstName="FirstName", lastName="LastName" >>>>>>>>>>> >>>>>>>>>>> But after it routes through the endpoint, the 2 parameters are >>>>>>>>>>> getting >>>>>>>>>>> null >>>>>>>>>>> values: >>>>>>>>>>> >>>>>>>>>>> location: null; >>>>>>>>>>> ModelTO: firstname=null, lastName=null. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> I have checked the camel-cxf code and enabled the Trace logging. >>>>>>>>>>> I >>>>>>>>>>> might >>>>>>>>>>> need additional logs in the invokeProxyClient method of the >>>>>>>>>>> CxfRsProducer to >>>>>>>>>>> see where the inMessage.getBody() values gets converted or loss >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>> >>> >>> >> > > > -- View this message in context: http://old.nabble.com/Null-parameters-when-routing-CXFRS-endpoints-tp28186748p28207107.html Sent from the Camel - Users mailing list archive at Nabble.com.