Examples of JAXRSClientFactoryBean


Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

    }
   
    @Test
    public void testGetPrimitiveIntArray() throws Exception {
        String address = "http://localhost:" + PORT;
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setProvider(new BookStore.PrimitiveIntArrayReaderWriter());
        bean.setAddress(address);
        bean.setResourceClass(BookStore.class);
        BookStore store = bean.create(BookStore.class);
        int[] arr = store.getBookIndexAsIntArray();
        assertEquals(3, arr.length);
        assertEquals(1, arr[0]);
        assertEquals(2, arr[1]);
        assertEquals(3, arr[2]);
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

    }
   
    @Test
    public void testGetPrimitiveDoubleArray() throws Exception {
        String address = "http://localhost:" + PORT;
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setProvider(new BookStore.PrimitiveDoubleArrayReaderWriter());
        bean.setAddress(address);
        bean.setResourceClass(BookStore.class);
        BookStore store = bean.create(BookStore.class);
        WebClient.getConfig(store).getHttpConduit().getClient().setReceiveTimeout(1000000L);
        double[] arr = store.getBookIndexAsDoubleArray();
        assertEquals(3, arr.length);
        assertEquals(1, arr[0], 0.0);
        assertEquals(2, arr[1], 0.0);
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

   
   
    @Test
    public void testGetStringList() throws Exception {
        String address = "http://localhost:" + PORT;
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setProvider(new BookStore.StringListBodyReaderWriter());
        bean.setAddress(address);
        bean.setResourceClass(BookStore.class);
        BookStore store = bean.create(BookStore.class);
        List<String> str = store.getBookListArray();
        assertEquals("Good book", str.get(0));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

    }
   
    @Test
    public void testEmptyPostProxy2() throws Exception {
        String address = "http://localhost:" + PORT;
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setAddress(address);
        bean.setResourceClass(BookStore.class);
        BookStore store = bean.create(BookStore.class);
        store.emptypostNoPath();
        assertEquals(204, WebClient.client(store).getResponse().getStatus());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

        String address = "https://localhost:" + PORT + "/xmlsig";
        doTestSignatureProxy(address, true, "file:");
    }
   
    private void doTestSignatureProxy(String address, boolean enveloping, String cryptoUrlPrefix) throws Exception {
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setAddress(address);
       
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
        Bus springBus = bf.createBus(busFile.toString());
        bean.setBus(springBus);

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("ws-security.callback-handler",
                       "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
        properties.put("ws-security.signature.username", "alice");
       
        String cryptoUrl = "org/apache/cxf/systest/jaxrs/security/alice.properties";
        if (cryptoUrlPrefix != null) {
            cryptoUrl = cryptoUrlPrefix + this.getClass().getResource("/" + cryptoUrl).toURI().getPath();
        }
        properties.put("ws-security.signature.properties", cryptoUrl);
        bean.setProperties(properties);
        XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
        if (enveloping) {
            sigInterceptor.setStyle(XmlSigOutInterceptor.ENVELOPING_SIG);
        }
        bean.getOutInterceptors().add(sigInterceptor);
        bean.setServiceClass(BookStore.class);
       
        BookStore store = bean.create(BookStore.class);
        try {
            Book book = store.addBook(new Book("CXF", 126L));
            assertEquals(126L, book.getId());
        } catch (WebApplicationException ex) {
            fail(ex.getMessage());
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

        String address = "https://localhost:" + PORT + "/xmlsig/bookstore/books";
        doTestSignature(address, true);
    }
   
    private void doTestSignature(String address, boolean enveloping) {
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setAddress(address);
       
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
        Bus springBus = bf.createBus(busFile.toString());
        bean.setBus(springBus);

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("ws-security.callback-handler",
                       "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
        properties.put("ws-security.signature.username", "alice");
        properties.put("ws-security.signature.properties",
                       "org/apache/cxf/systest/jaxrs/security/alice.properties");
        bean.setProperties(properties);
        XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
        if (enveloping) {
            sigInterceptor.setStyle(XmlSigOutInterceptor.ENVELOPING_SIG);
        }
        bean.getOutInterceptors().add(sigInterceptor);
        bean.getInInterceptors().add(new XmlSigInInterceptor());
       
        WebClient wc = bean.createWebClient();
        try {
            Book book = wc.post(new Book("CXF", 126L), Book.class);
            assertEquals(126L, book.getId());
        } catch (WebApplicationException ex) {
            fail(ex.getMessage());
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

        String address, boolean sign, Map<String, Object> properties,
        String keyIdentifierType, String symmetricAlgorithm,
        String digestAlgorithm,
        boolean propagateException
    ) throws Exception {
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setAddress(address);
       
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
        Bus springBus = bf.createBus(busFile.toString());
        bean.setBus(springBus);

        bean.setProperties(properties);
        if (sign) {
            bean.getOutInterceptors().add(new XmlSigOutInterceptor());
        }
        XmlEncOutInterceptor encInterceptor = new XmlEncOutInterceptor();
        encInterceptor.setKeyIdentifierType(keyIdentifierType);
        encInterceptor.setSymmetricEncAlgorithm(symmetricAlgorithm);
        encInterceptor.setDigestAlgorithm(digestAlgorithm);
        bean.getOutInterceptors().add(encInterceptor);
       
        bean.getInInterceptors().add(new XmlEncInInterceptor());
        if (sign) {
            bean.getInInterceptors().add(new XmlSigInInterceptor());
        }
       
       
        WebClient wc = bean.createWebClient();
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
        try {
            Book book = wc.post(new Book("CXF", 126L), Book.class);
            assertEquals(126L, book.getId());
        } catch (WebApplicationException ex) {
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

        client.headers(binding.bindCamelHeadersToRequestHeaders(inMessage.getHeaders(), exchange));
    }

    protected void invokeHttpClient(Exchange exchange) throws Exception {
        Message inMessage = exchange.getIn();
        JAXRSClientFactoryBean cfb = clientFactoryBeanCache.get(CxfEndpointUtils
            .getEffectiveAddress(exchange, ((CxfRsEndpoint)getEndpoint()).getAddress()));
        Bus bus = ((CxfRsEndpoint)getEndpoint()).getBus();
        // We need to apply the bus setting from the CxfRsEndpoint which is not use the default bus
        if (bus != null) {
            cfb.setBus(bus);
        }
        WebClient client = cfb.createWebClient();
        String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
        Class<?> responseClass = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Class.class);
        Type genericType = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_GENERIC_TYPE, Type.class);
        Object[] pathValues = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_VAR_VALUES, Object[].class);
        String path = inMessage.getHeader(Exchange.HTTP_PATH, String.class);
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

        Message inMessage = exchange.getIn();
        Object[] varValues = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_VAR_VALUES, Object[].class);
        String methodName = inMessage.getHeader(CxfConstants.OPERATION_NAME, String.class);
        Client target = null;
       
        JAXRSClientFactoryBean cfb = clientFactoryBeanCache.get(CxfEndpointUtils
                                   .getEffectiveAddress(exchange, ((CxfRsEndpoint)getEndpoint()).getAddress()));
        Bus bus = ((CxfRsEndpoint)getEndpoint()).getBus();
        // We need to apply the bus setting from the CxfRsEndpoint which is not use the default bus
        if (bus != null) {
            cfb.setBus(bus);
        }
        if (varValues == null) {
            target = cfb.create();
        } else {
            target = cfb.createWithValues(varValues);
        }
       
        setupClientHeaders(target, exchange);
       
        // find out the method which we want to invoke
        JAXRSServiceFactoryBean sfb = cfb.getServiceFactory();
        sfb.getResourceClasses();
        // check the null body first
        Object[] parameters = null;
        if (inMessage.getBody() != null) {
            parameters = inMessage.getBody(Object[].class);
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean

        public void stop() throws Exception {
            cache.clear();
        }

        public JAXRSClientFactoryBean get(String address) throws Exception {
            JAXRSClientFactoryBean retVal = null;
            synchronized (cache) {
                retVal = cache.get(address);
               
                if (retVal == null) {
                    retVal = ((CxfRsEndpoint)getEndpoint()).createJAXRSClientFactoryBean(address);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.