Search in sources :

Example 6 with ClientFactoryBean

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

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();
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean)

Example 8 with ClientFactoryBean

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();
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) CreditAgencyWS(org.apache.camel.loanbroker.credit.CreditAgencyWS)

Example 9 with ClientFactoryBean

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());
    }
}
Also used : PingMeFault(org.apache.cxf.greeter_control.PingMeFault) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) Greeter(org.apache.cxf.greeter_control.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 10 with ClientFactoryBean

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

ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)19 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)11 Test (org.junit.Test)10 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)6 URL (java.net.URL)2 Holder (javax.xml.ws.Holder)2 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 Client (org.apache.cxf.endpoint.Client)2 IOException (java.io.IOException)1 QName (javax.xml.namespace.QName)1 CreditAgencyWS (org.apache.camel.loanbroker.credit.CreditAgencyWS)1 SoapFault (org.apache.cxf.binding.soap.SoapFault)1 Greeter (org.apache.cxf.greeter_control.Greeter)1 PingMeFault (org.apache.cxf.greeter_control.PingMeFault)1 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)1 JaxWsClientFactoryBean (org.apache.cxf.jaxws.JaxWsClientFactoryBean)1 Greeter (org.apache.hello_world_soap_http.Greeter)1