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?



 <from uri="cxfrs://bean://rsServer"/>
       <!-- We can remove this configure as the CXFRS producer is using the
HttpAPI by default -->
       <setHeader headerName="CamelCxfRsVarValues">
           ?
       </setHeader>
  <to uri="cxfrs://bean://rsClient"/>

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?

<cxf:rsServer id="restRouter" address="/restRouter/"
serviceClass="com.project.service.impl.ServiceManagerImpl" />

<cxf:rsClient id="restEndpoint"
address="http://localhost:8080/services/rest";
serviceClass="com.project.service.impl.ServiceManagerImpl" />

<route>
     <from uri="cxfrs:bean:restRouter"/>
     <to uri="cxfrs:bean:restEndpoint"/>
</route>

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:

<route>
        <from uri="cxfrs:bean:serviceRouter" />
             <process ref="testProcessor" />
        <to uri="cxfrs:bean:serviceEndpoint?httpClientAPI=false" />
</route>

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










Reply via email to