[英]Proxy settings in Spring Boot
My application needs to fetch an XML file from the web, as follows: 我的应用程序需要从Web获取XML文件,如下所示:
@Bean
public HTTPMetadataProvider metadataProvider()
throws MetadataProviderException {
String metadataURL = "http://idp.ssocircle.com/idp-meta.xml";
final Timer backgroundTaskTimer = new Timer(true);
HTTPMetadataProvider provider =
new HTTPMetadataProvider(backgroundTaskTimer, httpClient(), metadataURL);
provider.setParserPool(parserPool());
return provider;
}
I'm working by using a filtered network, thus the app is unable to retrieve that file. 我正在使用过滤网络,因此应用程序无法检索该文件。
There is a way to setup an HTTP Proxy (eg myproxy.eu:8080
) in Spring Boot ? 有一种方法可以在Spring Boot中设置HTTP代理 (例如myproxy.eu:8080
)吗?
Alternatively, I could retrieve the XML file by using the HTTPS protocol, but I should properly setup the metadata provider in order to support an encrypted connection... How? 或者,我可以使用HTTPS协议检索XML文件,但我应该正确设置元数据提供程序以支持加密连接......如何?
This is not something you can configure in spring boot, HttpClient is not using java variables. 这不是你可以在spring boot中配置的东西,HttpClient不使用java变量。
Therefor you need to set the proxy on the httpClient manually: 因此,您需要手动在httpClient上设置代理:
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setProxyHost(new ProxyHost("your.proxy.host", 8080));
httpClient.setHostConfiguration(hostConfig);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.