protected void setupClientHeaders(Client client, Exchange exchange) throws Exception { Message inMessage = exchange.getIn(); CxfRsEndpoint cxfRsEndpoint = (CxfRsEndpoint) getEndpoint(); CxfRsBinding binding = cxfRsEndpoint.getBinding(); // set headers client.headers(binding.bindCamelHeadersToRequestHeaders(inMessage.getHeaders(), exchange)); }
private void invoke(int ind) throws Exception { 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); } }
/** * Creates a proxy, baseURI will be set to Client currentURI * @param client Client instance * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param inheritHeaders if true then existing Client headers will be inherited by new proxy * and subresource proxies if any * @return typed proxy */ public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) { JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null); bean.setInheritHeaders(inheritHeaders); ClientState clientState = WebClient.getClientState(client); T proxy = null; if (clientState == null) { proxy = bean.create(cls); if (inheritHeaders) { WebClient.client(proxy).headers(client.getHeaders()); } } else { MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null; bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null)); proxy = bean.create(cls); } WebClient.copyProperties(WebClient.client(proxy), client); return proxy; }
/** * Creates a proxy, baseURI will be set to Client currentURI * @param client Client instance * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param inheritHeaders if true then existing Client headers will be inherited by new proxy * and subresource proxies if any * @return typed proxy */ public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) { JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null); bean.setInheritHeaders(inheritHeaders); ClientState clientState = WebClient.getClientState(client); T proxy = null; if (clientState == null) { proxy = bean.create(cls); if (inheritHeaders) { WebClient.client(proxy).headers(client.getHeaders()); } } else { MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null; bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null)); proxy = bean.create(cls); } WebClient.copyProperties(WebClient.client(proxy), client); return proxy; }
/** * Creates a proxy, baseURI will be set to Client currentURI * @param client Client instance * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param inheritHeaders if true then existing Client headers will be inherited by new proxy * and subresource proxies if any * @return typed proxy */ public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) { JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null); bean.setInheritHeaders(inheritHeaders); ClientState clientState = WebClient.getClientState(client); T proxy = null; if (clientState == null) { proxy = bean.create(cls); if (inheritHeaders) { WebClient.client(proxy).headers(client.getHeaders()); } } else { MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null; bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null)); proxy = bean.create(cls); } WebClient.copyProperties(WebClient.client(proxy), client); return proxy; }