Search in sources :

Example 1 with ClientFactoryBean

use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.

the class CxfEndpoint method createClient.

/**
     * Create a CXF client object
     */
Client createClient() throws Exception {
    // get service class
    if (getDataFormat().equals(DataFormat.POJO)) {
        ObjectHelper.notNull(getServiceClass(), CxfConstants.SERVICE_CLASS);
    }
    if (getWsdlURL() == null && getServiceClass() == null) {
        // no WSDL and serviceClass specified, set our default serviceClass
        setServiceClass(org.apache.camel.component.cxf.DefaultSEI.class.getName());
        setDefaultOperationNamespace(CxfConstants.DISPATCH_NAMESPACE);
        setDefaultOperationName(CxfConstants.DISPATCH_DEFAULT_OPERATION_NAMESPACE);
        if (getDataFormat().equals(DataFormat.PAYLOAD)) {
            setSkipPayloadMessagePartCheck(true);
        }
    }
    Class<?> cls = null;
    if (getServiceClass() != null) {
        cls = getServiceClass();
        // create client factory bean
        ClientFactoryBean factoryBean = createClientFactoryBean(cls);
        // setup client factory bean
        setupClientFactoryBean(factoryBean, cls);
        Client client = factoryBean.create();
        // setup the handlers
        setupHandlers(factoryBean, client);
        return client;
    } else {
        // create the client without service class
        checkName(getPortName(), "endpoint/port name");
        checkName(getServiceName(), "service name");
        ClientFactoryBean factoryBean = createClientFactoryBean();
        // setup client factory bean
        setupClientFactoryBean(factoryBean, null);
        return factoryBean.create();
    }
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) Client(org.apache.cxf.endpoint.Client)

Example 2 with ClientFactoryBean

use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.

the class CxfSimpleRouterTest method getCXFClient.

protected HelloService getCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(getRouterAddress());
    clientBean.setServiceClass(HelloService.class);
    HelloService client = (HelloService) proxyFactory.create();
    return client;
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean)

Example 3 with ClientFactoryBean

use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.

the class CxfMixedModeRouterTest method getCXFClient.

protected HelloService getCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(ROUTER_ADDRESS);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.newInstance().createBus());
    HelloService client = (HelloService) proxyFactory.create();
    return client;
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean)

Example 4 with ClientFactoryBean

use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.

the class CxfPayLoadMessageXmlBindingRouterTest method getCXFClient.

protected HelloService getCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(ROUTER_ADDRESS);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBindingId(getBindingId());
    HelloService client = (HelloService) proxyFactory.create();
    return client;
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean)

Example 5 with ClientFactoryBean

use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.

the class WSRMTest method testWSAddressing.

@Test
public void testWSAddressing() throws Exception {
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(getClientAddress());
    clientBean.setServiceClass(HelloWorld.class);
    clientBean.setWsdlURL(WSRMTest.class.getResource("/HelloWorld.wsdl").toString());
    SpringBusFactory bf = new SpringBusFactory();
    URL cxfConfig = null;
    if (getCxfClientConfig() != null) {
        cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
    }
    proxyFactory.setBus(bf.createBus(cxfConfig));
    proxyFactory.getOutInterceptors().add(new MessageLossSimulator());
    HelloWorld client = (HelloWorld) proxyFactory.create();
    String result = client.sayHi("world!");
    assertEquals("Get a wrong response", "Hello world!", result);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)19 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)11 Test (org.junit.Test)10 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)6 URL (java.net.URL)2 Holder (javax.xml.ws.Holder)2 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 Client (org.apache.cxf.endpoint.Client)2 IOException (java.io.IOException)1 QName (javax.xml.namespace.QName)1 CreditAgencyWS (org.apache.camel.loanbroker.credit.CreditAgencyWS)1 SoapFault (org.apache.cxf.binding.soap.SoapFault)1 Greeter (org.apache.cxf.greeter_control.Greeter)1 PingMeFault (org.apache.cxf.greeter_control.PingMeFault)1 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)1 JaxWsClientFactoryBean (org.apache.cxf.jaxws.JaxWsClientFactoryBean)1 Greeter (org.apache.hello_world_soap_http.Greeter)1