Search in sources :

Example 1 with JaxWsProxyFactoryBean

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();
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean)

Example 2 with JaxWsProxyFactoryBean

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

Example 3 with JaxWsProxyFactoryBean

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);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 4 with JaxWsProxyFactoryBean

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()));
}
Also used : HTraceClientStopInterceptor(org.apache.cxf.tracing.htrace.HTraceClientStopInterceptor) Tracer(org.apache.htrace.core.Tracer) HTraceClientStartInterceptor(org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) List(java.util.List) Test(org.junit.Test)

Example 5 with JaxWsProxyFactoryBean

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;
}
Also used : LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client)

Aggregations

JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)152 Test (org.junit.Test)71 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)21 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)19 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)14 Greeter (org.apache.hello_world_soap_http.Greeter)14 Client (org.apache.cxf.endpoint.Client)13 HashMap (java.util.HashMap)10 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)9 QName (javax.xml.namespace.QName)8 WrappedGreeter (org.apache.hello_world_soap_action.WrappedGreeter)8 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)7 ArrayList (java.util.ArrayList)6 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)6 Holder (javax.xml.ws.Holder)5 Server (org.apache.cxf.endpoint.Server)5 Greeter (org.apache.cxf.greeter_control.Greeter)5 Service (org.apache.cxf.service.Service)5 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)5 Metadata (org.apache.cxf.ws.mex.model._2004_09.Metadata)5