Examples of HTTPConduit


Examples of org.apache.cxf.transport.http.HTTPConduit

    public void testAddGetImageWebClient() throws Exception {
        InputStream is1 =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg");
        String address = "http://localhost:" + PORT + "/bookstore/books/image";
        WebClient client = WebClient.create(address);
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/mixed").accept("multipart/mixed");
        InputStream is2 = client.post(is1, InputStream.class);
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
        byte[] image2 = IOUtils.readBytesFromStream(is2);
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

    public void testUploadImageFromForm() throws Exception {
        InputStream is1 =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg");
        String address = "http://localhost:" + PORT + "/bookstore/books/formimage";
        WebClient client = WebClient.create(address);
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        ContentDisposition cd = new ContentDisposition("attachment;filename=java.jpg");
        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
        headers.putSingle("Content-ID", "image");
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

        File file =
            new File(getClass().getResource("/org/apache/cxf/systest/jaxrs/resources/java.jpg")
                               .toURI().getPath());
        String address = "http://localhost:" + PORT + "/bookstore/books/formimage2";
        WebClient client = WebClient.create(address);
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        MultipartBody body2 = client.post(file, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

    private ConnectionHelper() {
    }

    public static void setKeepAliveConnection(Object proxy, boolean keepAlive) {
        Client client = ClientProxy.getClient(proxy);
        HTTPConduit hc = (HTTPConduit) client.getConduit();
        HTTPClientPolicy cp = hc.getClient();
        cp.setConnection(keepAlive ? ConnectionType.KEEP_ALIVE
                : ConnectionType.CLOSE);
    }
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

                : ConnectionType.CLOSE);
    }

    public static boolean isKeepAliveConnection(Object proxy) {
        Client client = ClientProxy.getClient(proxy);
        HTTPConduit hc = (HTTPConduit) client.getConduit();
        HTTPClientPolicy cp = hc.getClient();
        return cp.getConnection() == ConnectionType.KEEP_ALIVE;
    }
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

       
        decoupledEndpointPort--;
        decoupledEndpoint = "http://localhost:" + decoupledEndpointPort + "/decoupled_endpoint";

        Client c = ClientProxy.getClient(greeter);
        HTTPConduit hc = (HTTPConduit)(c.getConduit());
        HTTPClientPolicy cp = hc.getClient();
        cp.setDecoupledEndpoint(decoupledEndpoint);

        LOG.fine("Using decoupled endpoint: " + cp.getDecoupledEndpoint());
    }
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

    @Test
    public void testBasePetStoreWithoutTrailingSlash() throws Exception {
       
        String endpointAddress = "http://localhost:" + PORT + "/webapp/pets";
        WebClient client = WebClient.create(endpointAddress);
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        String value = client.accept("text/plain").get(String.class);
        assertEquals(PetStore.CLOSED, value);
    }
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

    @Test
    public void testBasePetStore() throws Exception {
       
        String endpointAddress = "http://localhost:" + PORT + "/webapp/pets/";
        WebClient client = WebClient.create(endpointAddress);
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        String value = client.accept("text/plain").get(String.class);
        assertEquals(PetStore.CLOSED, value);
    }
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

   
        HelloWorld hw = service.getPort(HelloWorld.class);
       
        Client cl = ClientProxy.getClient(hw);
       
        HTTPConduit http = (HTTPConduit) cl.getConduit();
        
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setConnectionTimeout(0);
        httpClientPolicy.setReceiveTimeout(0);
        
        http.setClient(httpClientPolicy);
   
        User user = new UserImpl("Barry");
        User user2 = hw.echoUser(user);
       
        assertNotSame(user, user2);
View Full Code Here

Examples of org.apache.cxf.transport.http.HTTPConduit

    public void testGetBook123Client() throws Exception {
       
        String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
        BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress,
                                                                  BookStoreJaxrsJaxws.class);
        HTTPConduit conduit = (HTTPConduit)WebClient.getConfig(proxy).getConduit();
       
        Book b = proxy.getBook(new Long("123"));
        assertEquals(123, b.getId());
        assertEquals("CXF in Action", b.getName());
       
        HTTPConduit conduit2 = (HTTPConduit)WebClient.getConfig(proxy).getConduit();
        assertSame(conduit, conduit2);
       
        conduit.getClient().setAutoRedirect(true);
        b = proxy.getBook(new Long("123"));
        assertEquals(123, b.getId());
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.