public static HttpResponse executeRequest(final String host, final int port, final boolean useSSL, final WebCall webCall, final List<String> remoteSupportedMimeTypes, final Serializable entity) throws ServiceException { HttpUriRequest request = null; IMarshaller marshaller = null; // determine the marshaller base on the specified remote mime-types if (remoteSupportedMimeTypes != null) { marshaller = determineCommonMimeType(remoteSupportedMimeTypes); } else if (webCall.getWebMethod().equalsIgnoreCase("POST")) { // if no mime-types were specified and its a POST request, then // throw exception - cannot serialize object without marshaller throw new ServiceException("Cannot call POST web-method without specifying the supported mime-types of the remote server!"); } if (webCall.getWebMethod().equalsIgnoreCase("GET")) { request = new HttpGet(buildURL(host, port, useSSL, webCall.getUri())); } else if (webCall.getWebMethod().equalsIgnoreCase("POST")) { request = new HttpPost(buildURL(host, port, useSSL, webCall.getUri())); ((HttpPost) request).setEntity(EntityBuilder.create().setBinary(marshaller.serialize(entity)).build()); } else if (webCall.getWebMethod().equalsIgnoreCase("DELETE")) { request = new HttpGet(buildURL(host, port, useSSL, webCall.getUri())); } else { throw new ServiceException("Unsupported web-call web method: " + webCall); } if (marshaller != null) { request.addHeader(HttpHeaders.CONTENT_TYPE, marshaller.getMimeType()); } request.addHeader(HttpHeaders.ACCEPT, getAcceptedMimeTypes()); return executeRequest(request, useSSL); }