Exemplo n.º 1
0
  private static boolean executeShoppingCartDSPlatformSample()
      throws IOException, SQLException, ParseException {
    Boolean sampleStatus = false;
    int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.DATA);
    String payload =
        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
            + "   <soapenv:Header/>\n"
            + "   <soapenv:Body/>\n"
            + "</soapenv:Envelope>";
    String action = "getAllCategories";

    try {
      OMElement result;
      result =
          sendRequest(
              payload,
              action,
              new EndpointReference(
                  StatusMonitorConstants.DATA_HTTP
                      + StatusMonitorAgentConstants.TENANT_SERVICES
                      + sampleTenantConfigBean.getTenant()
                      + "/ShoppingCartDS"));

      if ((result.toString().indexOf("Compact Lens-Shutter Cameras")) > 0) {
        sampleStatus = true;
        MySQLConnector.insertStats(serviceID, true);
        MySQLConnector.insertState(serviceID, true, "");
      } else {
        MySQLConnector.insertStats(serviceID, false);
        MySQLConnector.insertState(
            serviceID, false, "Platform sample ShoppingCartDS invocation failed");
      }
    } catch (AxisFault e) {
      MySQLConnector.insertStats(serviceID, false);
      MySQLConnector.insertState(
          serviceID, false, "Platform sample ShoppingCartDS: " + e.getMessage());
      String msg = "Fault in executing the Shopping cart sample";
      log.warn(msg, e);
    } catch (NullPointerException e) {
      MySQLConnector.insertStats(serviceID, false);
      MySQLConnector.insertState(
          serviceID, false, "Platform sample ShoppingCartDS: " + e.getMessage());
      String msg = "NPE in executing the shopping cart sample";
      log.warn(msg, e);
    } catch (XMLStreamException e) {
      String msg = "XMLStreamException in executing the shopping cart sample";
      log.warn(msg, e);
    }
    return sampleStatus;
  }
Exemplo n.º 2
0
  private static void executeService() throws IOException, SQLException, ParseException {
    int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.DATA);

    OMElement result;
    OMElement payload = createPayLoad();
    ServiceClient serviceclient = new ServiceClient();
    Options opts = new Options();
    opts.setTo(
        new EndpointReference(
            StatusMonitorConstants.DATA_HTTP
                + StatusMonitorAgentConstants.TENANT_SERVICES
                + authConfigBean.getTenant()
                + "/GSpreadSample"));
    opts.setAction("http://ws.wso2.org/dataservice/getCustomers");

    if (ServiceLoginClient.loginChecker(StatusMonitorConstants.DATA_HOST, serviceID)) {
      serviceclient.setOptions(opts);
      try {
        result = serviceclient.sendReceive(payload);
        if (log.isDebugEnabled()) {
          log.debug(result);
        }

        if ((result.toString().indexOf("Signal Gift Stores")) > 0) {
          executeShoppingCartDSPlatformSample();

        } else {
          MySQLConnector.insertStats(serviceID, false);
          MySQLConnector.insertState(serviceID, false, "Service Invocation failed");
        }

      } catch (AxisFault e) {
        MySQLConnector.insertStats(serviceID, false);
        MySQLConnector.insertState(serviceID, false, e.getMessage());
        String msg = "Error in executing service for DSS Server client";
        log.warn(msg, e);
      } catch (NullPointerException e) {
        MySQLConnector.insertStats(serviceID, false);
        MySQLConnector.insertState(serviceID, false, e.getMessage());
        String msg = "NPE in executing the service for DSS client";
        log.warn(msg, e);
      }
    }
  }