Package org.apache.cxf.jaxrs.client

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


        return taskPerFileResults;
    }

    private void initializeWebClient() {
        try {
            final Client client = WebClient.client(webService);
            WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(RECEIVE_TIMEOUT);
        } catch (Exception ignored) {
            //tymchenko: happens only in test!
            LOG.warn("Cannot set timeout for web services client. Probably you are running unit tests with a mock sequest search service?");
        }
View Full Code Here


        WORKFLOW_TYPE_MAP = Collections.unmodifiableMap(workflowTypeMap);
    }

    protected void initializeWebClient(long timeout) {
        try{
            final Client client = WebClient.client(translationService);
            WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(timeout);
        } catch (Exception ignored) {
            //tymchenko: happens only in test!
            Logger.getLogger(AbstractTranslationService.class).warn("Cannot set timeout for web services client. Probably you are running unit tests with a mock translation service?");
        }
View Full Code Here

    public void process(Exchange exchange) throws Exception {
        Message inMessage = exchange.getIn();
        Object[] varValues = inMessage.getHeader("VarValues", Object[].class);
        String methodName = inMessage.getHeader(CxfConstants.OPERATION_NAME, String.class);
        Client target = null;
        if (varValues == null) {
            target = cfb.create();
        } else {
            target = cfb.createWithValues(varValues);
        }   
View Full Code Here

    @Test
    public void testBookWithWebSocket() throws Exception {
        String address = "ws://localhost:" + getPort() + "/websocket";

        BookStoreWebSocket resource = JAXRSClientFactory.create(address, BookStoreWebSocket.class);
        Client client = WebClient.client(resource);
        client.header(HttpHeaders.USER_AGENT, JAXRSClientConduitWebSocketTest.class.getName());
       
        // call the GET service
        assertEquals("CXF in Action", new String(resource.getBookName()));

        // call the GET service in text mode
View Full Code Here

    protected void invokeProxyClient(Exchange exchange) throws Exception {
        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()));

        cfb.setBus(((CxfRsEndpoint)getEndpoint()).getBus());
       
        if (varValues == null) {
            target = cfb.create();
        } else {
            target = cfb.createWithValues(varValues);
        }
        // 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);
        }
        // get the method
        Method method = findRightMethod(sfb.getResourceClasses(), methodName, getParameterTypes(parameters));
        // Will send out the message to
        // Need to deal with the sub resource class
        Object response = method.invoke(target, parameters);
        int statesCode = target.getResponse().getStatus();
        if (throwException) {
            if (response instanceof Response) {
                Integer respCode = ((Response) response).getStatus();
                if (respCode > 207) {
                    throw populateCxfRsProducerException(exchange, (Response) response, respCode);
View Full Code Here

    protected void invokeProxyClient(Exchange exchange) throws Exception {
        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()));
       
        if (varValues == null) {
View Full Code Here

    protected void invokeProxyClient(Exchange exchange) throws Exception {
        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;
        if (varValues == null) {
            target = cfb.create();
        } else {
            target = cfb.createWithValues(varValues);
        }   
View Full Code Here

    @Test
    public void testBookWithWebSocket() throws Exception {
        String address = "ws://localhost:" + getPort() + "/websocket";

        BookStoreWebSocket resource = JAXRSClientFactory.create(address, BookStoreWebSocket.class);
        Client client = WebClient.client(resource);
        client.header(HttpHeaders.USER_AGENT, JAXRSClientConduitWebSocketTest.class.getName());
       
        // call the GET service
        assertEquals("CXF in Action", new String(resource.getBookName()));

        // call the GET service in text mode
View Full Code Here

    @Test
    public void testCallsWithIDReferences() throws Exception {
        String address = "ws://localhost:" + getPort() + "/websocket";

        BookStoreWebSocket resource = JAXRSClientFactory.create(address, BookStoreWebSocket.class, null, true);
        Client client = WebClient.client(resource);
        client.header(HttpHeaders.USER_AGENT, JAXRSClientConduitWebSocketTest.class.getName());
       
        // call the POST service twice (a unique requestId is automatically included to correlate the response)
        EchoBookIdRunner[] runners = new EchoBookIdRunner[2];
        runners[0] = new EchoBookIdRunner(resource, 549);
        runners[1] = new EchoBookIdRunner(resource, 495);
View Full Code Here

           
            String actualHeaderName = bookHeader + ind;
            String actualBookName = bookName + ind;
           
            if (stateCanBeChanged) {
                Client c = WebClient.client(proxy);
                MultivaluedMap<String, String> map = c.getHeaders();
                map.putSingle("CustomHeader", actualHeaderName);
                c.headers(map);
                proxy.echoBookNameAndHeader2(actualBookName);
                verifyResponse(c.getResponse(), actualBookName, actualHeaderName);
            } else {
                verifyResponse(proxy.echoBookNameAndHeader(actualHeaderName, actualBookName),
                               actualBookName, actualHeaderName);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.client.Client

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.