private String makeCall(HttpTransport transport) throws IOException { HttpRequest get = transport.createRequestFactory() .buildPostRequest(new GenericUrl(INRPUT_LOGIN_SERVER), null) .setFollowRedirects(false) .setThrowExceptionOnExecuteError(false); HttpResponse response = get.execute(); if (response.getStatusCode() != 302) { throw new IOException("Unexpected return code: " + response.getStatusCode() + "\nMessage:\n" + response.getStatusMessage()); } String cookieValue = response.getHeaders().getFirstHeaderStringValue("set-cookie"); if (Strings.isNullOrEmpty(cookieValue)) { throw new IOException("Couldn't extract cookie value from headers: " + response.getHeaders()); } return cookieValue; } }
/** Sets attributes of the request that are common to all requests for this handler. */ @Override public void initialize(HttpRequest httpRequest) throws IOException { // Do not throw if execute fails, since Axis will handle unmarshalling the // fault. httpRequest.setThrowExceptionOnExecuteError(false); // For consistency with the default Axis HTTPSender and CommonsHTTPSender, do not // follow redirects. httpRequest.setFollowRedirects(false); // Retry should be handled by the client. httpRequest.setNumberOfRetries(0); }
/** Sets attributes of the request that are common to all requests for this handler. */ @Override public void initialize(HttpRequest httpRequest) throws IOException { // Do not throw if execute fails, since Axis will handle unmarshalling the // fault. httpRequest.setThrowExceptionOnExecuteError(false); // For consistency with the default Axis HTTPSender and CommonsHTTPSender, do not // follow redirects. httpRequest.setFollowRedirects(false); // Retry should be handled by the client. httpRequest.setNumberOfRetries(0); }