use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class WSAddressingTest method testWSAddressing.
@Test
public void testWSAddressing() throws Exception {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(getClientAddress());
clientBean.setServiceClass(Greeter.class);
SpringBusFactory bf = new SpringBusFactory();
URL cxfConfig = null;
if (getCxfClientConfig() != null) {
cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
}
proxyFactory.setBus(bf.createBus(cxfConfig));
Greeter client = (Greeter) proxyFactory.create();
String result = client.greetMe("world!");
assertEquals("Get a wrong response", "Hello world!", result);
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class Client method getProxy.
public static LoanBrokerWS getProxy(String address) {
// Now we use the simple front API to create the client proxy
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(address);
clientBean.setServiceClass(LoanBrokerWS.class);
// just create a new bus for use
clientBean.setBus(BusFactory.newInstance().createBus());
return (LoanBrokerWS) proxyFactory.create();
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CreditScoreProcessor method getProxy.
private CreditAgencyWS getProxy() {
// Here we use JaxWs front end to create the proxy
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(creditAgencyAddress);
clientBean.setServiceClass(CreditAgencyWS.class);
clientBean.setBus(BusFactory.getDefaultBus());
return (CreditAgencyWS) proxyFactory.create();
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class JaxWsWebFaultAnnotationToFaultTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(ROUTER_ADDRESS);
clientBean.setServiceClass(Greeter.class);
Greeter client = (Greeter) proxyFactory.create();
try {
client.pingMe();
fail("Expect to get an exception here");
} catch (PingMeFault expected) {
assertEquals(MESSAGE, expected.getMessage());
} catch (Throwable t) {
t.printStackTrace();
fail("The CXF client did not manage to map the client exception " + t.getClass().getName() + " to a " + PingMeFault.class.getName() + ": " + t.getMessage());
}
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class LoggingInterceptorInMessageModeTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
LoggingOutInterceptor logInterceptor = null;
for (Interceptor<?> interceptor : context.getEndpoint("cxf:bean:serviceEndpoint", CxfSpringEndpoint.class).getOutInterceptors()) {
if (interceptor instanceof LoggingOutInterceptor) {
logInterceptor = LoggingOutInterceptor.class.cast(interceptor);
break;
}
}
assertNotNull(logInterceptor);
// StringPrintWriter writer = new StringPrintWriter();
// Unfortunately, LoggingOutInterceptor does not have a setter for writer so
// we can't capture the output to verify.
// logInterceptor.setPrintWriter(writer);
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(ROUTER_ADDRESS);
clientBean.setServiceClass(HelloService.class);
HelloService client = (HelloService) proxyFactory.create();
String result = client.echo("hello world");
assertEquals("we should get the right answer from router", result, "echo hello world");
//assertTrue(writer.getString().indexOf("hello world") > 0);
}
Aggregations