Ejemplo n.º 1
0
  /**
   * Students by name
   *
   * @param studentNames
   * @return
   */
  public List<Student> getStudentsByName(List<String> studentNames) {

    Client client = ClientBuilder.newClient();
    WebTarget myResource =
        client
            .target(BASE_URL + "/studentsByName")
            .queryParam("names", converter.toString(studentNames));

    StudentWrapper wrapper = null;
    try {

      wrapper = myResource.request(MediaType.APPLICATION_JSON).get(StudentWrapper.class);

    } catch (Exception e) {
      System.out.println("Exception : " + e.getMessage());
      e.printStackTrace();
    }
    return wrapper.getList();
  }
Ejemplo n.º 2
0
  /**
   * @param studentNames
   * @return
   */
  public List<Student> getStudentsByNameJson(List<String> studentNames) {

    Client client = ClientBuilder.newClient();
    String nameJson = converter.toJson(studentNames);
    WebTarget myResource = client.target(BASE_URL + "/studentsByNameJson");

    StudentWrapper wrapper = null;
    try {

      wrapper =
          myResource
              .request(MediaType.APPLICATION_JSON)
              .put(Entity.text(nameJson), StudentWrapper.class);

    } catch (Exception e) {
      System.out.println("Exception : " + e.getMessage());
      e.printStackTrace();
    }
    return wrapper.getList();
  }