Jagger
 All Classes Namespaces Files Functions Variables Groups Pages
final HttpResponse com.griddynamics.jagger.invoker.http.ApacheAbstractHttpInvoker< Q >.invoke ( query,
String  endpoint 
) throws InvocationException

Executes http request via apache http client.

Author
Mairbek Khadikov
Parameters
query- input data for the invocation
endpoint- url of target service
Returns
apache http response
Exceptions
InvocationExceptionwhen invocation failed
63  {
64  Preconditions.checkNotNull(query);
65  Preconditions.checkNotNull(endpoint);
66 
67  HttpRequestBase method = null;
68  HttpEntity response = null;
69  try {
70  method = getHttpMethod(query, endpoint);
71  method.setParams(getHttpClientParams(query));
72 
73  org.apache.http.HttpResponse httpResponse = httpClient.execute(method);
74  response = httpResponse.getEntity();
75  return HttpResponse.create(httpResponse.getStatusLine().getStatusCode(), EntityUtils.toString(response));
76  } catch (Exception e) {
77  if (method != null) {
78  log.debug("Error during invocation with URL: " + method.getURI() +
79  ", endpoint: " + endpoint + ", query: " + query, e);
80  } else {
81  log.debug("Error during invocation with: endpoint: " + endpoint + ", query: " + query, e);
82  }
83  throw new InvocationException("InvocationException : ", e);
84  } finally {
85  EntityUtils.consumeQuietly(response);
86  }
87  }