I have been trying to set up a CXF endpoint in Camel, using spring java config like so:
@Bean
public CxfEndpoint anEndpoint() {
CxfEndpoint endpoint = new CxfEndpoint();
endpoint.setAddress(getEndpointUrl());
endpoint.setServiceClass(ServiceSOAP.class);
endpoint.setWsdlURL("/wsdl/ServiceSOAP.wsdl");
String httpProxyHost = httpProxyHost();
String httpProxyPort = httpProxyPort();
Map<String, Object> properties = new HashMap<>();
properties.put("https.proxyHost", httpProxyHost());
properties.put("https.proxyPort", httpProxyPort());
properties.put("http.proxyHost", httpProxyHost());
properties.put("http.proxyPort", httpProxyPort());
endpoint.setProperties(properties);
return endpoint;
}
However, this is not working on either http or https endpoint urls.
I have also tried setting these properties on CamelContext directly with the same result.
The route is working fine in the environment with a direct connection to the internet, e.g., locally, but not where it is deployed behind an http proxy.
We're using apache camel 2.15.2 and apache cxf 3.1.0. Any help is greatly appreciated!
The resolution turned out to be simple if tortuous to figure out. One has to use a CxfEndpointConfigurator to set up HTTPConduit properties like so:
@Bean
public CxfEndpoint anEndpoint() {
CxfEndpoint endpoint = new CxfEndpoint();
endpoint.setAddress(getEndpointUrl());
endpoint.setServiceClass(ServiceSOAP.class);
endpoint.setWsdlURL("/wsdl/ServiceSOAP.wsdl");
endpoint.setCxfEndpointConfigurer(anEndpointClientConfigurer());
return endpoint;
}
private CxfEndpointConfigurer anEndpointClientConfigurer() {
return new CxfEndpointConfigurer() {
@Override
public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
}
@Override
public void configureClient(Client client) {
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setProxyServer(httpProxyHost());
policy.setProxyServerPort(httpProxyPort());
conduit.setClient(policy);
}
}