Vertx客户端,用于发送带参数

时间:2017-10-30 08:20:42

标签: vertx-httpclient

我在Vertx中编写客户端,用于发送带有两个字符串参数的get请求,但我从服务器接收空列表。如果我将请求写入同一路径上的另一个服务但该服务未接收任何参数,则响应正常并且数据已正确返回。问题是在服务器端使用.addQueryParam映射参数时,参数未在服务器端很好地映射。有什么帮助吗?

WebClient client = WebClient.create(vertx);
client
.get(80, "localhost", "/mainpath/path1")
.addQueryParam("startDate", "1459926000")
.addQueryParam("endDate", "1459926900")
.send(ar -> {
    if (ar.succeeded()) {
      HttpResponse<Buffer> response = ar.result();
      JsonArray body = response.bodyAsJsonArray();
      System.out.println("Received response with status code " + response.statusCode() + " with body " + body.toString());
    } else {
      System.out.println("Something went wrong " + ar.cause().getMessage());
    }
  });
}

0 个答案:

没有答案