p.setDecoupledEndpoint(v); } else if ("ProxyServer".equals(k)) { p.setProxyServer(v); } else if ("ProxyServerPort".equals(k)) { p.setProxyServerPort(Integer.parseInt(v.trim()));
HTTPClientPolicy policy = new HTTPClientPolicy(); policy.setProxyServer("<<proxyServer>>"); policy.setProxyServerPort("<<proxyPort>>"); httpConduit.setClient(policy);
private static HTTPClientPolicy createSystemProxyConfiguration() { // Retrieve system properties (if any) HTTPClientPolicy systemProxyConfiguration = null; String proxyHost = SystemPropertyAction.getPropertyOrNull(HTTP_PROXY_HOST); if (StringUtils.isEmpty(proxyHost)) { proxyHost = null; } if (proxyHost != null) { // System is configured with a proxy, use it systemProxyConfiguration = new HTTPClientPolicy(); systemProxyConfiguration.setProxyServer(proxyHost); systemProxyConfiguration.setProxyServerType(ProxyServerType.HTTP); // 8080 is the default proxy port value as per some documentation String proxyPort = SystemPropertyAction.getProperty(HTTP_PROXY_PORT, "8080"); if (StringUtils.isEmpty(proxyPort)) { proxyPort = "8080"; } systemProxyConfiguration.setProxyServerPort(Integer.parseInt(proxyPort)); // Load non proxy hosts String nonProxyHosts = SystemPropertyAction.getPropertyOrNull(HTTP_NON_PROXY_HOSTS); if (!StringUtils.isEmpty(nonProxyHosts)) { systemProxyConfiguration.setNonProxyHosts(nonProxyHosts); } } return systemProxyConfiguration; }
HTTPClientPolicy policy = new HTTPClientPolicy(); policy.setProxyServer(System.getProperty("http.proxyHost")); policy.setProxyServerPort(Integer.valueOf(System.getProperty("http.proxyPort")).intValue()); httpConduit.setClient(policy);
/** * Set the proxy server values for a service port * * @param serviceApi * The service port Object * @param server * The name of the proxy server, ex. proxy.example.com * @param port * The port of the proxy server, ex. 3128 * @param type * The type of proxy server: HTTP or Socks * */ protected void setProxyServer(Object serviceApi, String server, int port, ProxyServerType type) { if (serviceApi != null) { logger.debug("Set proxy server for service: {} ({}:{}, {})", serviceApi.toString(), server, port, type); org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(serviceApi); HTTPConduit http = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setProxyServer(server); httpClientPolicy.setProxyServerPort(port); httpClientPolicy.setProxyServerType(type); http.setClient(httpClientPolicy); } }
WebClient client = WebClient.create(xmlFilePath ,String.class,null); client = client.type(MediaType.APPLICATION_XML); HTTPConduit httpConduit = (HTTPConduit)WebClient.getConfig(client).getConduit(); HTTPClientPolicy policy = new HTTPClientPolicy(); policy.setProxyServer(proxyurl); policy.setProxyServerPort(8080); httpConduit.setClient(policy); Response r = client.post(); InputStream response= (InputStream)r.getEntity();
p.setDecoupledEndpoint(StringUtils.combine(p1.getDecoupledEndpoint(), p2.getDecoupledEndpoint())); p.setHost(StringUtils.combine(p1.getHost(), p2.getHost())); p.setProxyServer(StringUtils.combine(p1.getProxyServer(), p2.getProxyServer())); if (p1.isSetProxyServerPort()) { p.setProxyServerPort(p1.getProxyServerPort());
private void setConnectionProperties(Map<String, Object> configProps, ClientConfiguration clientCfg) { Long connTimeOutValue = getLongValue(configProps.get(HTTP_CONNECTION_TIMEOUT_PROP)); if (connTimeOutValue != null) { clientCfg.getHttpConduit().getClient().setConnectionTimeout(connTimeOutValue); } Long recTimeOutValue = getLongValue(configProps.get(HTTP_RECEIVE_TIMEOUT_PROP)); if (recTimeOutValue != null) { clientCfg.getHttpConduit().getClient().setReceiveTimeout(recTimeOutValue); } Object proxyServerValue = configProps.get(HTTP_PROXY_SERVER_PROP); if (proxyServerValue != null) { clientCfg.getHttpConduit().getClient().setProxyServer((String)proxyServerValue); } Integer proxyServerPortValue = getIntValue(configProps.get(HTTP_PROXY_SERVER_PORT_PROP)); if (proxyServerPortValue != null) { clientCfg.getHttpConduit().getClient().setProxyServerPort(proxyServerPortValue); } Boolean autoRedirectValue = getBooleanValue(configProps.get(HTTP_AUTOREDIRECT_PROP)); if (autoRedirectValue != null) { clientCfg.getHttpConduit().getClient().setAutoRedirect(autoRedirectValue); } Boolean mantainSessionValue = getBooleanValue(configProps.get(HTTP_MAINTAIN_SESSION_PROP)); if (mantainSessionValue != null) { clientCfg.getRequestContext().put(Message.MAINTAIN_SESSION, mantainSessionValue); } }
/** * {@inheritDoc} */ @Override public void onProxyChange(ProxySettings proxySettings) { HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnection(ConnectionType.CLOSE); httpClientPolicy.setAllowChunking(true); httpClientPolicy.setCacheControl("no-cache"); if (proxySettings.isEnabled()) { httpClientPolicy.setProxyServer(proxySettings.getProxyHost()); httpClientPolicy.setProxyServerPort(proxySettings.getProxyPort()); httpClientPolicy.setProxyServerType(ProxyServerType.HTTP); } else { httpClientPolicy.setProxyServer(null); httpClientPolicy.setProxyServerPort(null); httpClientPolicy.setProxyServerType(null); } Client client = ClientProxy.getClient(pronomService); HTTPConduit http = (HTTPConduit) client.getConduit(); http.setClient(httpClientPolicy); }
private void setConnectionProperties(Map<String, Object> configProps, ClientConfiguration clientCfg) { Long connTimeOutValue = getLongValue(configProps.get(HTTP_CONNECTION_TIMEOUT_PROP)); if (connTimeOutValue != null) { clientCfg.getHttpConduit().getClient().setConnectionTimeout(connTimeOutValue); } Long recTimeOutValue = getLongValue(configProps.get(HTTP_RECEIVE_TIMEOUT_PROP)); if (recTimeOutValue != null) { clientCfg.getHttpConduit().getClient().setReceiveTimeout(recTimeOutValue); } Object proxyServerValue = configProps.get(HTTP_PROXY_SERVER_PROP); if (proxyServerValue != null) { clientCfg.getHttpConduit().getClient().setProxyServer((String)proxyServerValue); } Integer proxyServerPortValue = getIntValue(configProps.get(HTTP_PROXY_SERVER_PORT_PROP)); if (proxyServerPortValue != null) { clientCfg.getHttpConduit().getClient().setProxyServerPort(proxyServerPortValue); } Boolean autoRedirectValue = getBooleanValue(configProps.get(HTTP_AUTOREDIRECT_PROP)); if (autoRedirectValue != null) { clientCfg.getHttpConduit().getClient().setAutoRedirect(autoRedirectValue); } Boolean mantainSessionValue = getBooleanValue(configProps.get(HTTP_MAINTAIN_SESSION_PROP)); if (mantainSessionValue != null) { clientCfg.getRequestContext().put(Message.MAINTAIN_SESSION, mantainSessionValue); } }
p.setDecoupledEndpoint(v); } else if ("ProxyServer".equals(k)) { p.setProxyServer(v); } else if ("ProxyServerPort".equals(k)) { p.setProxyServerPort(Integer.parseInt(v.trim()));
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); }
/** * {@inheritDoc} */ @Override public void onProxyChange(ProxySettings proxySettings) { HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnection(ConnectionType.CLOSE); httpClientPolicy.setAllowChunking(true); httpClientPolicy.setCacheControl(ClientCacheControlType.NO_CACHE); if (proxySettings.isEnabled()) { httpClientPolicy.setProxyServer(proxySettings.getProxyHost()); httpClientPolicy.setProxyServerPort(proxySettings.getProxyPort()); httpClientPolicy.setProxyServerType(ProxyServerType.HTTP); } else { httpClientPolicy.setProxyServer(null); httpClientPolicy.unsetProxyServerPort(); httpClientPolicy.setProxyServerType(null); } Client client = ClientProxy.getClient(pronomService); HTTPConduit http = (HTTPConduit) client.getConduit(); http.setClient(httpClientPolicy); }
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); }
private static HTTPClientPolicy createSystemProxyConfiguration() { // Retrieve system properties (if any) HTTPClientPolicy systemProxyConfiguration = null; String proxyHost = SystemPropertyAction.getPropertyOrNull(HTTP_PROXY_HOST); if (StringUtils.isEmpty(proxyHost)) { proxyHost = null; } if (proxyHost != null) { // System is configured with a proxy, use it systemProxyConfiguration = new HTTPClientPolicy(); systemProxyConfiguration.setProxyServer(proxyHost); systemProxyConfiguration.setProxyServerType(ProxyServerType.HTTP); // 8080 is the default proxy port value as per some documentation String proxyPort = SystemPropertyAction.getProperty(HTTP_PROXY_PORT, "8080"); if (StringUtils.isEmpty(proxyPort)) { proxyPort = "8080"; } systemProxyConfiguration.setProxyServerPort(Integer.parseInt(proxyPort)); // Load non proxy hosts String nonProxyHosts = SystemPropertyAction.getPropertyOrNull(HTTP_NON_PROXY_HOSTS); if (!StringUtils.isEmpty(nonProxyHosts)) { systemProxyConfiguration.setNonProxyHosts(nonProxyHosts); } } return systemProxyConfiguration; }
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); ProxyAuthorizationPolicy auth = new ProxyAuthorizationPolicy(); auth.setUserName("CXF"); auth.setPassword("password"); cond.setProxyAuthorization(auth); }
private static HTTPClientPolicy createSystemProxyConfiguration() { // Retrieve system properties (if any) HTTPClientPolicy systemProxyConfiguration = null; String proxyHost = SystemPropertyAction.getPropertyOrNull(HTTP_PROXY_HOST); if (StringUtils.isEmpty(proxyHost)) { proxyHost = null; } if (proxyHost != null) { // System is configured with a proxy, use it systemProxyConfiguration = new HTTPClientPolicy(); systemProxyConfiguration.setProxyServer(proxyHost); systemProxyConfiguration.setProxyServerType(ProxyServerType.HTTP); // 8080 is the default proxy port value as per some documentation String proxyPort = SystemPropertyAction.getProperty(HTTP_PROXY_PORT, "8080"); if (StringUtils.isEmpty(proxyPort)) { proxyPort = null; } systemProxyConfiguration.setProxyServerPort(Integer.valueOf(proxyPort)); // Load non proxy hosts String nonProxyHosts = SystemPropertyAction.getPropertyOrNull(HTTP_NON_PROXY_HOSTS); if (!StringUtils.isEmpty(nonProxyHosts)) { systemProxyConfiguration.setNonProxyHosts(nonProxyHosts); } } return systemProxyConfiguration; }
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); ProxyAuthorizationPolicy auth = new ProxyAuthorizationPolicy(); auth.setUserName("CXF"); auth.setPassword("password"); cond.setProxyAuthorization(auth); }
clientPolicy.setProxyServer(getProxyHost()); clientPolicy.setProxyServerPort(getProxyPort());
@Test public void testConnectionWithProxy() throws Exception { QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService"); HelloService service = new HelloService(null, serviceName); assertNotNull(service); Hello hello = service.getHelloPort(); Client client = ClientProxy.getClient(hello); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); HTTPConduit http = (HTTPConduit)client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setAllowChunking(false); httpClientPolicy.setReceiveTimeout(0); httpClientPolicy.setProxyServerType(ProxyServerType.HTTP); httpClientPolicy.setProxyServer("localhost"); httpClientPolicy.setProxyServerPort(PROXY_PORT); http.setClient(httpClientPolicy); ((BindingProvider)hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello"); assertEquals("getSayHi", hello.sayHi("SayHi")); } }