|
|
|
@ -21,15 +21,20 @@ public class HttpService {
|
|
|
|
|
|
|
|
|
|
public JSONObject post(String url, JSONObject postData) {
|
|
|
|
|
log.debug("Service call: {}", url);
|
|
|
|
|
JSONObject response = new JSONObject(Optional.ofNullable(client
|
|
|
|
|
.post()
|
|
|
|
|
.uri(url)
|
|
|
|
|
.contentType(MediaType.APPLICATION_JSON)
|
|
|
|
|
.body(BodyInserters.fromValue(postData.toString()))
|
|
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
|
|
.retrieve()
|
|
|
|
|
.bodyToMono(String.class)
|
|
|
|
|
.block()).orElse("{response:\"empty\"}"));
|
|
|
|
|
JSONObject response = null;
|
|
|
|
|
try {
|
|
|
|
|
response = new JSONObject(Optional.ofNullable(client
|
|
|
|
|
.post()
|
|
|
|
|
.uri(url)
|
|
|
|
|
.contentType(MediaType.APPLICATION_JSON)
|
|
|
|
|
.body(BodyInserters.fromValue(postData.toString()))
|
|
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
|
|
.retrieve()
|
|
|
|
|
.bodyToMono(String.class)
|
|
|
|
|
.toFuture().get()).orElse("{response:\"empty\"}"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return new JSONObject("{response:\"empty\"}");
|
|
|
|
|
}
|
|
|
|
|
log.debug("Service response: {}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|