I'm trying to call via SOAP over an HTTPS Proxy with Apache CXF.
It's a Java Application running on Cloud Foundry. The Proxy is provided as a Cloud Foundry service. Rest calls are working with via configuration in a RestTemplateCustomizer.
I tried the following (I tried every commended statement without success):
PortType port = cs.getServicePort();
assert port instanceof BindingProvider;
BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceURL);
//bp.getRequestContext().put("https.proxyHost", endpoint.getHost());
//bp.getRequestContext().put("https.proxyPort", endpoint.getPort());
final Client client = ClientProxy.getClient(port);
final HTTPConduit http = (HTTPConduit) client.getConduit();
http.getClient().setProxyServer(endpoint.getHost());
http.getClient().setProxyServerPort(endpoint.getPort());
http.getProxyAuthorization().setUserName(configProperties.getUser());
http.getProxyAuthorization().setPassword(configProperties.getPassword());
//http.getProxyAuthorization().setAuthorizationType("Basic");
//http.getClient().setProxyServerType(ProxyServerType.SOCKS);
http.getAuthorization().setUserName(configProperties.getUser());
http.getAuthorization().setPassword(configProperties.getPassword());
//http.getAuthorization().setAuthorizationType("Basic");
Stacktrace looks like:
2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT javax.xml.ws.WebServiceException: Could not send Message. 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:183) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at com.sun.proxy.$Proxy288.getConfigurations(Unknown Source)
#2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT Caused by: java.io.IOException: IOException invoking https://service.com/services/Service/v1 : Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required" 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1402) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1386) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.transport.AbstractConduit.close(AbstractCondu it.java:56) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:673) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:440) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.frontend.Client Proxy.invokeSync(ClientProxy.java:96) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140) 2019-05-16T11:11:53.76+0200 [APP/PROC/WEB/0] OUT ... 131 common frames omitted
Found a solution. I had to set the following flag:
-Djdk.http.auth.tunneling.disabledSchemes=""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.