【发布时间】:2017-01-12 15:24:22
【问题描述】:
即使我在代理后面,我也可以使用不同的浏览器和 Postman 成功访问以下 OData 服务:
String SERVICE_ROOT =http://services.odata.org/V4/TripPinService/
但是,在 Java 中使用 Apache Olingo 我无法访问此服务。
-Dhttp.proxySet=true -Dhttp.proxyHost=http-proxy.example.com -Dhttp.proxyPort=8080 等 JVM 参数允许我执行基本的 URL 功能,例如检索 HTTP 状态代码(谷歌返回 200)。然而,使用 ODataClient 访问 OData-Service 是不可能的(下面的代码)。没有错误被抛出。
ODataClient client = ODataClientFactory.getClient();
ODataServiceDocumentRequest request = client.getRetrieveRequestFactory().getServiceDocumentRequest(SERVICE_ROOT);
ODataRetrieveResponse<ClientServiceDocument> response = request.execute();
我尝试在 Olingo 中使用代理功能,但没有任何成功:
client.getConfiguration().setHttpClientFactory(new ProxyWrappingHttpClientFactory(URI.create("http://http-proxy.example.com:8080")));
我做错了什么,我还有什么选择?
非常感谢。
【问题讨论】:
标签: java apache proxy odata olingo