@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { // create a method call final MethodCall call = MethodCall.create(method.getName(), args); // send the request to the remote service final HttpResponse response = ServiceUtils.executeRequest(serviceDescriptor, serviceDescriptor.getServiceUri(), call); if (response.getEntity() != null && response.getEntity().getContentLength() > 0 && response.getHeaders(HttpHeaders.CONTENT_TYPE) != null && response.getHeaders(HttpHeaders.CONTENT_TYPE).length > 0) { // deserialize with the marshaller for the response content-type final String mimeType = ServiceUtils.getMimeTypeFromResponse(response); final IMarshaller responseMarshaller = MarshallerFactory.get(mimeType); if (responseMarshaller == null) { LOG.error("Could not find a marshaller for the response content-type: " + mimeType); throw new ServiceException("Could not find a marshaller for the response content-type: " + mimeType); } return responseMarshaller.deserialize(response.getEntity().getContent(), method.getReturnType()); } return null; }
final String mimeType = ServiceUtils.getMimeTypeFromResponse(response); final IMarshaller responseMarshaller = MarshallerFactory.get(mimeType);