Я использую Jersey 2.11 для доступа к REST API слияния и получения оттуда контента.
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
....
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(
"confluenceUsername", "confluencePassword"
);
ClientConfig cc = new ClientConfig();
cc.property(ClientProperties.PROXY_URI, "xx.xx.xx.xx:xxxx");
Client client = ClientBuilder.newClient(cc);
client.register(feature);
WebTarget target = client.target(credential.getUrl())
.path("rest").path("api").path("content").path(id)
.queryParam("expand", "space,body.storage,version,container,ancestors");
Response response = target.request().get();
Является ли это текущим правильным способом использования прокси в Java с Jersey 2.11? Я всегда получаю исключение
java.net.ConnectException: Connection refused: connect
javax.ws.rs.ProcessingException: java.net.Connect Exception: Connection refused: connect
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:229)
...
Сайт слияния, к которому я хочу получить доступ, использует https. На машине, которой не нужен прокси, он работает
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(
"confluenceUsername", "confluencePassword");
Client client = ClientBuilder.newClient();
client.register(feature);
так что Confluence - не проблема. Я думаю, что что-то не так со спецификацией прокси, но не знаю что.