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();
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations