Found my answer in the source of CxfBeanEndpoint:
...
        Object obj = 
serviceBeans.get(0).getClass().getAnnotation(WebService.class);

        if (obj != null) {
            JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
            bean.setTransportId(CxfBeanTransportFactory.TRANSPORT_ID);
            bean.setServiceClass(serviceBeans.get(0).getClass());
            // set the bean instance as well, otherwise CXF will re-create a 
new instance of the class
            bean.setServiceBean(serviceBeans.get(0));
...
So indeed only the first JAXWS been is considered per endpoint.

Thanks
Jan 

-----Original Message-----
From: Jansen, Jan Arend [mailto:jan.arend.jan...@wolterskluwer.com] 
Sent: Tuesday, July 08, 2014 10:43 AM
To: users@camel.apache.org
Subject: RE: Can I use a single cxfbean endpoint for multiple services?

Willem,

Thanks for your reply. Indeed that is what my 'normal' route looks like, a 
proxy and a backed service with some transformations in-between as camel 
components. My goal is to have an alternative route that doesn't handoff to the 
backend service, but to a mock implementation of the WSDL contract that is 
deployed as an OSGI bundle as well. I could deploy the mock as a WAR, but I 
prefer to use cxfbean: and route to it using direct-vm:. The problem is not to 
make that work (it already does), but it seems that I need to split the 
incoming message based on headers to the right 
cxfbean:<<jaxws-annotated-bean>>. I was wondering if it cannot be done simpler 
as the cxfbean component allows a <list> of beans to be injected, but only the 
first of those seems to be considered. What I thought would work (but only 
works for the first bean in the list) was:

    <util:list id="serviceBeanList">
        <ref bean="accountsMock"/>
        <ref bean="productsMock"/>
        <ref bean="authorizationMock"/>
    </util:list>
    <bean id="accountsMock" class="com.example.AccountsMock" />
    <bean id="productsMock" class="com.example.ProductsMock" />
    <bean id="authorizationMock" class="com.example.AuthorizationMock" />

    <camelContext id="ext-camel-context">
        <route id="mocks">
            <from uri="direct-vm: mocks" />
            <to uri="cxfbean:serviceBeanList" />
        </route>
    </camelContext>

The three services are all part of the same WSDL and the Mock classes are using 
the generated stubs from cxf's wsdl2java tool

Jan
-----Original Message-----
From: Willem Jiang [mailto:willem.ji...@gmail.com]
Sent: Tuesday, July 08, 2014 5:10 AM
To: users@camel.apache.org
Subject: Re: Can I use a single cxfbean endpoint for multiple services?

cxfbean is suppose to invoke the service implentation object directly.
You use case is just like a proxy, my suggestion is you can just delegate the 
request to back end service by using camel-http component directly. You don’t 
need to use camel-cxfbean this time.

--
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem



On July 7, 2014 at 11:16:02 PM, Jansen, Jan Arend 
(jan.arend.jan...@wolterskluwer.com) wrote:
> Hi,
>  
> I have a WSDL with several services defined. I would like to use the
> cxfbean: uri to define mock implementations of the generated JAX-WS 
> stubs on Karaf as an alternative route to the real endpoints sitting outside 
> of the runtime.
>  
> Is it possible to provide a single endpoint that can consume any 
> incoming exchange as long as its service is defined in the WSDL or do 
> I need to split and route (for example on
> SoapAction) to the correct JAXWS annotated bean for the service impl?
>  
> Thanks,
> Jan
>  

Reply via email to