@NotNull public HttpUriRequest createRequest( @NotNull Descriptors.MethodDescriptor method, @NotNull Message request) throws IOException, URISyntaxException { final HttpPost post = new HttpPost( baseUri.resolve( method.getService().getName().toLowerCase() + "/" + method.getName().toLowerCase() + format.getSuffix())); post.setHeader(HttpHeaders.CONTENT_TYPE, format.getMimeType()); post.setHeader(HttpHeaders.CONTENT_ENCODING, StandardCharsets.UTF_8.name()); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); format.write(request, stream, StandardCharsets.UTF_8); post.setEntity(new ByteArrayEntity(stream.toByteArray())); return post; }
@Override public void callMethod( @NotNull Descriptors.MethodDescriptor method, @NotNull RpcController controller, @NotNull Message request, @NotNull RpcCallback<Message> done) { try { done.run(service.callBlockingMethod(method, controller, request)); } catch (ServiceException e) { log.error("Blocking method error " + method.getFullName(), e); done.run(null); } }