2017-09-01 4 views
1

Ich habe versucht, einen CXF Endpunkt in Camel einzurichten, spring java Config wie so verwenden:Apache Camel CXF Endpunkt - http (s) Proxy angeben?

@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; 
} 

Dies ist jedoch nicht funktioniert entweder http oder https Endpunkt URLs.

Ich habe auch versucht, diese Eigenschaften auf CamelContext direkt mit dem gleichen Ergebnis zu setzen.

Die Route funktioniert gut in der Umgebung mit einer direkten Verbindung zum Internet, z. B. lokal, aber nicht wo es hinter einem http-Proxy bereitgestellt wird.

Wir verwenden Apache Camel 2.15.2 und Apache CXF 3.1.0. Jede Hilfe wird sehr geschätzt!

Antwort

2

Die Auflösung stellte sich als einfach heraus, wenn sie sich quälend herausstellte. Man hat eine CxfEndpointConfigurator zu verwenden, um Eigenschaften einzurichten HTTPConduit wie 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); 
      } 
     } 

Referenzen: 1 und 2

Verwandte Themen