Grails-Plugin-Consortium / grails-cxf-client

Easy cxf client for grails
http://grails.org/plugin/cxf-client
27 stars 30 forks source link

Setting proxy information #46

Closed Sabst closed 9 years ago

Sabst commented 10 years ago

Hi, Proxy information (host and port) either in config or before invoking the service cannot be set.

As a side note, I found code like this one below but could not figure out how to make it work with the CXF client plugin... that could be a workaround as configuration of the proxy is not available yet.

Thanks for the great plugin, Stephane.

HTTPClientPolicy policy = new HTTPClientPolicy(); policy.setProxyServer(proxyHost); policy.setProxyServerPort(proxyPort); httpConduit.setClient(policy);

Sabst commented 10 years ago

Finally found the httpClientPolicy bean and that did the trick... The bean does the job but I failed to do it at run-time as shown in the original question though... I am interested if anyone knows how to do it.

ctoestreich commented 9 years ago

You can do this like the following in the config as below. See http://cxf.apache.org/javadoc/latest/org/apache/cxf/transports/http/configuration/HTTPClientPolicy.html for more properties you can set on the policy

resources.groovy

beans = { customHttpClientPolicy(HTTPClientPolicy){ connectionTimeout = 30000 receiveTimeout = 60000 allowChunking = false autoRedirect = false proxyServer = '10.1.1.1' proxyServerPort = 8080 } } Config.groovy

cxf { client { simpleServiceClient { clientInterface = cxf.client.demo.simple.SimpleServicePortType serviceEndpointAddress = "${service.simple.url}" httpClientPolicy = 'customHttpClientPolicy' } }

Sabst commented 9 years ago

Thank you!