Package org.apache.cxf.frontend

Examples of org.apache.cxf.frontend.ClientFactoryBean


        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/XmlBindingRouterContext.xml");
    }
   
    protected HelloService getCXFClient() throws Exception {
        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
        clientBean.setAddress(ROUTER_ADDRESS);
        clientBean.setServiceClass(HelloService.class);
        clientBean.setBindingId(getBindingId());
       
        HelloService client = (HelloService) proxyFactory.create();
        return client;
    }
View Full Code Here


    }

    @Test
    public void testWSAddressing() throws Exception {
        JaxWsProxyFactoryBean proxyFactory = new  JaxWsProxyFactoryBean();
        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
        clientBean.setAddress("http://localhost:9000/SoapContext/SoapPort");
        clientBean.setServiceClass(Greeter.class);
        SpringBusFactory bf = new SpringBusFactory();
        URL cxfConfig = null;

        if (getCxfClientConfig() != null) {
            cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
        }
        clientBean.setBus(bf.createBus(cxfConfig));
        Greeter client = (Greeter) proxyFactory.create();
        String result = client.greetMe("world!");
        assertEquals("Get a wrong response", "Hello world!", result);
    }
View Full Code Here

    }

    @Test
    public void testInvokingServiceFromCXFClient() throws Exception {
        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
        clientBean.setAddress(ROUTER_ADDRESS);
        clientBean.setServiceClass(HelloService.class);
        clientBean.setBus(bus);

        HelloService client = (HelloService) proxyFactory.create();

        try {
            client.echo("hello world");
View Full Code Here

                protected Client createClient(Endpoint ep) {
                    return new CamelCxfClientImpl(getBus(), ep);
                }
            });
        } else {
            return new ClientProxyFactoryBean(new ClientFactoryBean() {
                @Override
                protected Client createClient(Endpoint ep) {
                    return new CamelCxfClientImpl(getBus(), ep);
                }
            });
View Full Code Here

    /**
     *
     * Create a client factory bean object without serviceClass interface.
     */
    protected ClientFactoryBean createClientFactoryBean() {
        return new ClientFactoryBean(new WSDLServiceFactoryBean()) {
                       
            @Override
            protected Client createClient(Endpoint ep) {
                return new CamelCxfClientImpl(getBus(), ep);
            }
View Full Code Here

    // END SNIPPET: example

    @Test
    public void testInvokingServiceFromCXFClient() throws Exception {
        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
        clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
        clientBean.setServiceClass(HelloService.class);
        clientBean.setBus(BusFactory.getDefaultBus());

        HelloService client = (HelloService) proxyFactory.create();

        String result = client.echo(TEST_MESSAGE);
        assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
View Full Code Here

            setupClientFactoryBean(factoryBean, cls);
            return ((ClientProxy)Proxy.getInvocationHandler(factoryBean.create())).getClient();
        } else {
            ObjectHelper.notNull(portName, "Please provide endpoint/port name");
            ObjectHelper.notNull(serviceName, "Please provide service name");
            ClientFactoryBean factoryBean = createClientFactoryBean();
            // setup client factory bean
            setupClientFactoryBean(factoryBean);
            return factoryBean.create();
        }
       
    }
View Full Code Here

        // 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");
View Full Code Here

     * Create a client factory bean object.  Notice that the serviceClass <b>must</b> be
     * an interface.
     */
    protected ClientProxyFactoryBean createClientFactoryBean(Class<?> cls) throws CamelException {       
        if (cls == null && !getDataFormat().equals(DataFormat.POJO)) {
            return new ClientProxyFactoryBean(new ClientFactoryBean(new WSDLServiceFactoryBean()) {
                @Override
                protected void createClient(Endpoint ep) {
                    setClient(new CamelCxfClientImpl(getBus(), ep));
                }   
               
                protected void initializeAnnotationInterceptors(Endpoint ep, Class<?> cls) {
                    // Do nothing here
                }
               
            })
            {   // Override the ClientProxyFactoryBean's create method
                // Don't create the proxy object
                public Object create() {
               
                    if (getProperties() == null) {
                        setProperties(new HashMap<String, Object>());
                    }
                   
                    if (getUsername() != null) {
                        AuthorizationPolicy authPolicy = new AuthorizationPolicy();
                        authPolicy.setUserName(getUsername());
                        authPolicy.setPassword(getPassword());
                        getProperties().put(AuthorizationPolicy.class.getName(), authPolicy);
                    }
                   
                    initFeatures();               
                    getClientFactoryBean().setProperties(getProperties());
                   
                    if (bus != null) {
                        getClientFactoryBean().setBus(bus);
                    }

                    if (getDataBinding() != null) {
                        getClientFactoryBean().setDataBinding(getDataBinding());
                    }
                   
                    Client c = getClientFactoryBean().create();
                    if (getInInterceptors() != null) {
                        c.getInInterceptors().addAll(getInInterceptors());
                    }
                    if (getOutInterceptors() != null) {
                        c.getOutInterceptors().addAll(getOutInterceptors());
                    }
                    if (getInFaultInterceptors() != null) {
                        c.getInFaultInterceptors().addAll(getInFaultInterceptors());
                    }
                    if (getOutFaultInterceptors() != null) {
                        c.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
                    }

                    return c;
                }
            };       
        }
       
        // quick null point check for serviceClass
        //ObjectHelper.notNull(cls, "Please provide endpoint service interface class");
       
        if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
            return new JaxWsProxyFactoryBean(new JaxWsClientFactoryBean() {
                @Override
                protected void createClient(Endpoint ep) {
                    setClient(new CamelCxfClientImpl(getBus(), ep));
                }
            });
        } else {
            return new ClientProxyFactoryBean(new ClientFactoryBean() {
                @Override
                protected void createClient(Endpoint ep) {
                    setClient(new CamelCxfClientImpl(getBus(), ep));
                }
            });
View Full Code Here

    // END SNIPPET: example

    @Test
    public void testInvokingServiceFromCXFClient() throws Exception {
        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
        clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
        clientBean.setServiceClass(HelloService.class);
        clientBean.setBus(BusFactory.getDefaultBus());

        HelloService client = (HelloService) proxyFactory.create();

        String result = client.echo(TEST_MESSAGE);
        assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
View Full Code Here

TOP

Related Classes of org.apache.cxf.frontend.ClientFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.