@Override
  public OMElement prepareResponseOMElement()
      throws InvalidInputException, RequestHandlerException, OperationFailedException, Exception {
    OMElement response = null;
    OMElement selectedNode = null;
    ServiceUtilities serviceUtil = new ServiceUtilities();
    String siteId = null;

    // siteId
    if ((selectedNode =
            serviceUtil.getNode(
                this.inputMsg,
                NETWORK_MONITORING_SERVICE_NS,
                nsPrefix,
                QueryEndpointsRequest.getSiteIDXPath(namespace)))
        != null) {
      siteId = selectedNode.getText().trim();
    } else {
      Object[] args = new Object[1];
      args[0] = RequestResponseConstants.RAW_SITEID;
      throw new InvalidInputException(
          DracErrorConstants.WS_MISSING_PARAMETER_IN_REQUEST_MESSAGE, args);
    }

    List<EndpointResourceUiType> endpoints = rh.getEndpointsForSiteId(token, siteId);

    if (nsPrefix.equals("xmlns")) {
      nsPrefix = "";
    }
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace(NETWORK_MONITORING_SERVICE_NS, nsPrefix);
    response = fac.createOMElement(RequestResponseConstants.RAW_QUERY_ENDPOINTS_RESPONSE, ns);
    OMElement numOfElements =
        fac.createOMElement(RequestResponseConstants.RAW_NUM_OF_ELEMENTS_INCLUDED, ns, response);
    OMElement totalNumOfElements =
        fac.createOMElement(
            RequestResponseConstants.RAW_TOTAL_NUM_OF_MATCHING_ELEMENTS, ns, response);

    // Dead code
    // if (endpoints == null) {
    // numOfElements.setText("0");
    // totalNumOfElements.setText("0");
    // return response;
    // }
    if (endpoints.isEmpty()) {
      numOfElements.setText("0");
      totalNumOfElements.setText("0");
      return response;
    }
    boolean reducedList = true;
    totalNumOfElements.setText(new Integer(endpoints.size()).toString());
    if (endpoints.size() < CommonConstants.MAX_NUM_OF_ENDPOINTS_TO_BE_RETRIEVED) {
      numOfElements.setText(new Integer(endpoints.size()).toString());
      reducedList = false;
    } else {
      numOfElements.setText(
          new Integer(CommonConstants.MAX_NUM_OF_ENDPOINTS_TO_BE_RETRIEVED).toString());
    }
    int i = 0;
    for (EndpointResourceUiType endpoint : endpoints) {

      OMElement tna = fac.createOMElement(RequestResponseConstants.RAW_TNA, ns, response);
      tna.setText(endpoint.getTna());

      i++;
      if (reducedList && i == CommonConstants.MAX_NUM_OF_ENDPOINTS_TO_BE_RETRIEVED) {
        break;
      }
    }
    return response;
  }