use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project camel by apache.
the class ReportIncidentRoutesTest method createCXFClient.
protected static ReportIncidentEndpoint createCXFClient(String url) {
// we use CXF to create a client for us as its easier than JAXWS and works
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ReportIncidentEndpoint.class);
factory.setAddress(url);
return (ReportIncidentEndpoint) factory.create();
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean 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);
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean 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.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class HTraceTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvided.
@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvided() throws MalformedURLException {
final Tracer tracer = createTracer();
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getOutInterceptors().add(new HTraceClientStartInterceptor(tracer));
factory.getInInterceptors().add(new HTraceClientStopInterceptor());
}
});
assertThat(service.getBooks().size(), equalTo(2));
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(3));
assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
assertThat(TestSpanReceiver.getAllSpans().get(0).getParents().length, equalTo(1));
assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("POST /BookStore"));
assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), not(nullValue()));
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class HTraceTracingTest method createJaxWsService.
private BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Configurator configurator) throws MalformedURLException {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.setServiceClass(BookStoreService.class);
factory.setAddress("http://localhost:" + PORT + "/BookStore");
if (configurator != null) {
configurator.configure(factory);
}
final BookStoreService service = (BookStoreService) factory.create();
final Client proxy = ClientProxy.getClient(service);
proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
return service;
}
Aggregations