Search in sources :

Example 21 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.

the class RountripTest method testServerFactoryBean.

@Test
public void testServerFactoryBean() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    svrBean.setServiceBean(new HelloServiceImpl());
    svrBean.setServiceClass(HelloService.class);
    svrBean.setBus(getBus());
    svrBean.create();
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress("http://localhost/Hello");
    clientBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(getBus());
    HelloService client = (HelloService) proxyFactory.create();
    assertEquals("hello", client.sayHello());
    assertEquals("hello", client.echo("hello"));
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Test(org.junit.Test)

Example 22 with ClientProxyFactoryBean

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

the class FailOverFeatureTest method tryFailover.

private String tryFailover(String url) {
    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    factory.setServiceClass(HelloService.class);
    factory.setAddress(url);
    HelloService client = (HelloService) factory.create();
    return client.sayHello();
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean)

Example 23 with ClientProxyFactoryBean

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

the class CxfPayLoadBareSoapTest method testInvokeProxyService.

@Test
public void testInvokeProxyService() {
    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    factory.setServiceClass(BareSoapService.class);
    factory.setAddress(PROXY_URL);
    factory.setBus(BusFactory.newInstance().createBus());
    BareSoapService client = (BareSoapService) factory.create();
    client.doSomething();
    assertEquals("Proxied service should have been invoked once", 1, IMPLEMENTATION.invocations.get());
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Test(org.junit.Test)

Example 24 with ClientProxyFactoryBean

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

the class LoadDistributorFeatureTest method tryLoadDistributor.

private String tryLoadDistributor(String url) {
    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    factory.setServiceClass(HelloService.class);
    factory.setAddress(url);
    HelloService client = (HelloService) factory.create();
    return client.sayHello();
}
Also used : ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean)

Example 25 with ClientProxyFactoryBean

use of org.apache.cxf.frontend.ClientProxyFactoryBean 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);
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Test(org.junit.Test)

Aggregations

ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)43 Test (org.junit.Test)23 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)12 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)12 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)10 Client (org.apache.cxf.endpoint.Client)4 Server (org.apache.cxf.endpoint.Server)4 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)4 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)3 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)3 Before (org.junit.Before)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 Document (org.w3c.dom.Document)3 CustomerService (com.example.customerservice.CustomerService)2 HashMap (java.util.HashMap)2 QName (javax.xml.namespace.QName)2 AegisContext (org.apache.cxf.aegis.AegisContext)2 JaxbElementTest (org.apache.cxf.jaxb_element_test.JaxbElementTest)2 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)2 Service (org.apache.cxf.service.Service)2