我正在尝试使用Apache CXF通过SOAP通过HTTPS代理进行调用。
这是一个在Cloud Foundry上运行的Java应用程序。代理作为Cloud Foundry服务提供。 Rest调用通过RestTemplateCustomizer中的配置进行处理。
我尝试了以下操作(我尝试了每条推荐的语句都没有成功):
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看起来像:
2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0] OUT javax.xml.ws.WebServiceException:无法发送消息。 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:183)处退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在com.sun.proxy。$ Proxy288.getConfigurations(未知来源)
#2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0] OUT原因:java.io.IOException:IOException调用https://service.com/services/Service/v1:无法通过代理进行隧道传输。代理返回“需要HTTP / 1.1 407代理身份验证” 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在java.lang.reflect.Constructor.newInstance(Constructor.java:423)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.mapException(HTTPConduit.java:1402)处输出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.close(HTTPConduit.java:1386)处输出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:673)处输出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.interceptor.MessageSenderInterceptor $ MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63)上退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)处退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)上退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:440)处输出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)上退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)处退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0]在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)处退出 2019-05-16T11:11:53.76 + 0200 [APP / PROC / WEB / 0] OUT ...省略了131个常见帧
答案 0 :(得分:0)
找到了解决方案。我必须设置以下标志:
-Djdk.http.auth.tunneling.disabledSchemes=""