private int getMaxRetransmits() { HTTPClientPolicy policy = getClient(outMessage); // Default MaxRetransmits is -1 which means unlimited. return (policy == null) ? -1 : policy.getMaxRetransmits(); }
HelloService hello = new HelloService(); HelloPortType helloPort = cliente.getHelloPort(); org.apache.cxf.endpoint.Client client = ClientProxy.getClient(helloPort); HTTPConduit http = (HTTPConduit) client.getConduit(); http.getClient().setProxyServer("proxy"); http.getClient().setProxyServerPort(8080); http.getProxyAuthorization().setUserName("user proxy"); http.getProxyAuthorization().setPassword("password proxy");
/** * This call gets called by the HTTPTransportFactory after it * causes an injection of the Spring configuration properties * of this Conduit. */ public void finalizeConfig() { // See if not set by configuration, if there are defaults // in order from the Endpoint, Service, or Bus. configureConduitFromEndpointInfo(this, endpointInfo); logConfig(); if (getClient().getDecoupledEndpoint() != null) { this.endpointInfo.setProperty("org.apache.cxf.ws.addressing.replyto", getClient().getDecoupledEndpoint()); } }
public void assertMessage(Message message) { PolicyDataEngine policyDataEngine = bus.getExtension(PolicyDataEngine.class); policyDataEngine.assertMessage(message, getClient(), new ClientPolicyCalculator()); }
/** * This procedure handles all retransmits, if any. * * @throws IOException */ protected void handleRetransmits() throws IOException { // If we have a cachedStream, we are caching the request. if (cachedStream != null || getClient().isAutoRedirect() && KNOWN_HTTP_VERBS_WITH_NO_CONTENT.contains(getMethod()) || authSupplier != null && authSupplier.requiresRequestCaching()) { if (LOG.isLoggable(Level.FINE) && cachedStream != null) { StringBuilder b = new StringBuilder(4096); b.append("Conduit \"").append(getConduitName()) .append("\" Transmit cached message to: ") .append(url) .append(": "); cachedStream.writeCacheTo(b, 16L * 1024L); LOG.fine(b.toString()); } int maxRetransmits = getMaxRetransmits(); updateCookiesBeforeRetransmit(); int nretransmits = 0; while ((maxRetransmits < 0 || nretransmits < maxRetransmits) && processRetransmit()) { nretransmits++; } } } /**
private void applyClientPolicies(Dictionary<String, String> d, HTTPConduit c) { Enumeration<String> keys = d.keys(); HTTPClientPolicy p = c.getClient(); while (keys.hasMoreElements()) { String k = keys.nextElement();
public void connect(TokenHolder tokenHolder) { for (Class<? extends PublicInterface> interface1 : interfaces) { JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean(); cpfb.setServiceClass(interface1); cpfb.setAddress(address + "/" + interface1.getSimpleName()); Map<String, Object> properties = new HashMap<String, Object>(); properties.put("mtom-enabled", Boolean.TRUE); cpfb.setProperties(properties); PublicInterface serviceInterface = (PublicInterface) cpfb.create(); client = ClientProxy.getClient(serviceInterface); HTTPConduit http = (HTTPConduit) client.getConduit(); http.getClient().setConnectionTimeout(360000); http.getClient().setAllowChunking(false); http.getClient().setReceiveTimeout(320000); if (!useSoapHeaderSessions) { ((BindingProvider) serviceInterface).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); } add(interface1.getName(), serviceInterface); } tokenHolder.registerTokenChangeListener(this); notifyOfConnect(); }
protected boolean redirectRetransmit() throws IOException { if (!getClient(outMessage).isAutoRedirect()) { return false;
HTTPClientPolicy policy = getClient(outMessage); boolean exceptionSet = outMessage.getContent(Exception.class) != null; if (!exceptionSet) {
private static void configureConduitFromEndpointInfo(HTTPConduit conduit, EndpointInfo endpointInfo) { if (conduit.getClient() == null) { conduit.setClient(endpointInfo.getTraversedExtensor( new HTTPClientPolicy(), HTTPClientPolicy.class)); } if (conduit.getAuthorization() == null) { conduit.setAuthorization(endpointInfo.getTraversedExtensor( new AuthorizationPolicy(), AuthorizationPolicy.class)); } if (conduit.getProxyAuthorization() == null) { conduit.setProxyAuthorization(endpointInfo.getTraversedExtensor( new ProxyAuthorizationPolicy(), ProxyAuthorizationPolicy.class)); } if (conduit.getTlsClientParameters() == null) { conduit.setTlsClientParameters(endpointInfo.getTraversedExtensor( null, TLSClientParameters.class)); } if (conduit.getTrustDecider() == null) { conduit.setTrustDecider(endpointInfo.getTraversedExtensor(null, MessageTrustDecider.class)); } if (conduit.getAuthSupplier() == null) { conduit.setAuthSupplier(endpointInfo.getTraversedExtensor(null, HttpAuthSupplier.class)); } }
public static void setKeepAliveConnection(Object proxy, boolean keepAlive, boolean force) { if (force || "HP-UX".equals(System.getProperty("os.name")) || "Windows XP".equals(System.getProperty("os.name"))) { Client client = ClientProxy.getClient(proxy); HTTPConduit hc = (HTTPConduit)client.getConduit(); HTTPClientPolicy cp = hc.getClient(); cp.setConnection(keepAlive ? ConnectionType.KEEP_ALIVE : ConnectionType.CLOSE); } }
protected WebClient createWebClient(final String url, final String media) { final List< ? > providers = Arrays.asList(new JacksonJsonProvider()); final WebClient wc = WebClient .create("http://localhost:" + getPort() + url, providers) .accept(media); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(8000L); return wc; }
private void doTestGetBookISOXML(String charset, String pathSegment) throws Exception { String address = "http://localhost:" + PORT + "/the/bookstore/ISO-8859-1/" + pathSegment; WebClient wc = WebClient.create(address); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L); wc.accept("application/xml" + (charset == null ? "" : ";charset=ISO-8859-1")); byte[] iso88591bytes = wc.get(byte[].class); String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1"); String name = helloStringISO88591.substring( helloStringISO88591.indexOf("<name>") + "<name>".length(), helloStringISO88591.indexOf("</name>")); compareNames(name); }
protected WebClient createWebClient(final String url) { WebClient wc = WebClient.create("http://localhost:" + PORT + url) .accept(MediaType.APPLICATION_JSON); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L); return wc; }
public void configureProxy(Client client) { HTTPConduit cond = (HTTPConduit)client.getConduit(); HTTPClientPolicy pol = cond.getClient(); if (pol == null) { pol = new HTTPClientPolicy(); cond.setClient(pol); } pol.setProxyServer("localhost"); pol.setProxyServerPort(PROXY_PORT); }
@Test public void testMatchedUrisParam() throws Exception { WebClient wc = WebClient.create("http://localhost:" + PORT + "/match/my/resource/1/matched/uris/param"); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L); wc.accept("text/plain"); String data = wc.get(String.class); assertEquals("my/resource/1/matched/uris/param,my/resource/1", data); } @Test
@Test public void testMatchedResources() throws Exception { WebClient wc = WebClient.create("http://localhost:" + PORT + "/match/my/resource/1/matched/resources"); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L); wc.accept("text/plain"); String data = wc.get(String.class); assertEquals("class org.apache.cxf.systest.jaxrs.JAXRSUriInfoMatchTest$Resource", data); }
@Test public void testBookExistsServerAddressOverwriteWithQuery() throws Exception { String address = "http://localhost:" + PORT + "/bookstore/books/checkNQuery?a=b"; WebClient wc = WebClient.create(address); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000); wc.accept("text/plain").type("text/plain"); assertTrue(wc.post("s", Boolean.class)); }
@Test public void testUseProxyToAddBookAndSimpleParts() throws Exception { MultipartStore store = JAXRSClientFactory.create("http://localhost:" + PORT, MultipartStore.class); HTTPConduit conduit = WebClient.getConfig(store).getHttpConduit(); conduit.getClient().setReceiveTimeout(1000000); Book b = store.testAddBookAndSimpleParts(new Book("CXF in Action", 124L), "1", 2); assertEquals(124L, b.getId()); assertEquals("CXF in Action - 12", b.getName()); }