/*
   * (non-Javadoc)
   *
   * @see
   * com.google.code.magja.service.category.CategoryAttributeRemoteService#listAll
   * (java.lang.String)
   */
  @Override
  public List<CategoryAttribute> listAll(String storeView) throws ServiceException {

    List<CategoryAttribute> results = new ArrayList<CategoryAttribute>();

    List<Map<String, Object>> attributes = null;
    try {
      attributes =
          (List<Map<String, Object>>) soapClient.call(ResourcePath.CategoryAttributeList, "");
    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (attributes == null) return results;

    for (Map<String, Object> att : attributes) {

      CategoryAttribute attribute = new CategoryAttribute();

      for (Map.Entry<String, Object> attr : att.entrySet())
        attribute.set(attr.getKey(), attr.getValue());

      // verify options
      if (att.get("type") != null) {
        String type = (String) att.get("type");
        if (type.equals("select") || type.equals("multiselect")) {

          List<Object> optParamList = new LinkedList<Object>();
          optParamList.add(att.get("attribute_id"));
          optParamList.add(storeView);

          List<Map<String, Object>> optList = null;
          try {
            optList =
                (List<Map<String, Object>>)
                    soapClient.call(ResourcePath.CategoryAttributeOptions, optParamList);
          } catch (AxisFault e) {
            if (debug) e.printStackTrace();
            throw new ServiceException(e.getMessage());
          }

          if (optList != null) {
            for (Map<String, Object> optAtt : optList) {

              CategoryAttributeOption option = new CategoryAttributeOption();
              option.setLabel((String) optAtt.get("label"));
              option.setValue(optAtt.get("value"));

              attribute.getOptions().add(option);
            }
          }
        }
      }

      results.add(attribute);
    }

    return results;
  }
  private static boolean axis2ServiceTest() {
    boolean axis2ServiceStatus = false;

    OMElement result;
    try {
      OMElement payload = createPayLoad();
      ServiceClient serviceclient = new ServiceClient();
      Options opts = new Options();

      opts.setTo(new EndpointReference(HTTP_APPSERVER_STRATOSLIVE_URL + "/Axis2Service"));
      opts.setAction("http://service.carbon.wso2.org/echoString");
      opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
      serviceclient.setOptions(opts);

      result = serviceclient.sendReceive(payload);

      if ((result.toString().indexOf("Hello World")) > 0) {
        axis2ServiceStatus = true;
      }
      assertTrue("Axis2Service invocation failed", axis2ServiceStatus);

    } catch (AxisFault axisFault) {
      log.error("Axis2Service invocation failed :" + axisFault.getMessage());
      fail("Axis2Service invocation failed :" + axisFault.getMessage());
    }

    return axis2ServiceStatus;
  }
Example #3
0
  private void handleFault(MessageContext synCtx, Exception ex) {
    synCtx.setProperty(SynapseConstants.SENDING_FAULT, Boolean.TRUE);

    if (ex != null && ex instanceof AxisFault) {
      AxisFault axisFault = (AxisFault) ex;

      if (axisFault.getFaultCodeElement() != null) {
        synCtx.setProperty(SynapseConstants.ERROR_CODE, axisFault.getFaultCodeElement().getText());
      } else {
        synCtx.setProperty(SynapseConstants.ERROR_CODE, SynapseConstants.CALLOUT_OPERATION_FAILED);
      }

      if (axisFault.getMessage() != null) {
        synCtx.setProperty(SynapseConstants.ERROR_MESSAGE, axisFault.getMessage());
      } else {
        synCtx.setProperty(
            SynapseConstants.ERROR_MESSAGE, "Error while performing " + "the call operation");
      }

      if (axisFault.getFaultDetailElement() != null) {
        if (axisFault.getFaultDetailElement().getFirstElement() != null) {
          synCtx.setProperty(
              SynapseConstants.ERROR_DETAIL, axisFault.getFaultDetailElement().getFirstElement());
        } else {
          synCtx.setProperty(
              SynapseConstants.ERROR_DETAIL, axisFault.getFaultDetailElement().getText());
        }
      }
    }

    synCtx.setProperty(SynapseConstants.ERROR_EXCEPTION, ex);
    throw new SynapseException("Error while performing the call operation", ex);
  }
  private static boolean JARServiceTest() {
    boolean JARServiceStatus = false;
    OMElement result;
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2", "ns1");
    OMElement payload = fac.createOMElement("echo", omNs);
    OMElement value = fac.createOMElement("args0", omNs);
    value.addChild(fac.createOMText(value, "Hello-World"));
    payload.addChild(value);

    ServiceClient serviceclient;
    try {
      serviceclient = new ServiceClient();
      Options opts = new Options();

      opts.setTo(new EndpointReference(HTTP_APPSERVER_STRATOSLIVE_URL + "/SimpleJarService"));
      opts.setAction("echo");
      // bypass http protocol exception
      opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);

      serviceclient.setOptions(opts);

      result = serviceclient.sendReceive(payload);

      if ((result.toString().indexOf("Hello-World")) > 0) {
        JARServiceStatus = true;
      }
      assertTrue("Jar service invocation failed", JARServiceStatus);

    } catch (AxisFault axisFault) {
      log.error("Jar service invocation failed:" + axisFault.getMessage());
      fail("Jar service invocation failed:" + axisFault.getMessage());
    }
    return JARServiceStatus;
  }
  public static OMElement sendReceive(
      OMElement payload, String endPointReference, String operation, String contentType)
      throws AxisFault {

    ServiceClient sender;
    Options options;
    OMElement response = null;
    if (log.isDebugEnabled()) {
      log.debug("Service Endpoint : " + endPointReference);
      log.debug("Service Operation : " + operation);
      log.debug("Payload : " + payload);
    }
    try {
      sender = new ServiceClient();
      options = new Options();
      options.setTo(new EndpointReference(endPointReference));
      options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
      options.setTimeOutInMilliSeconds(45000);
      options.setAction("urn:" + operation);
      options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
      options.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType);
      sender.setOptions(options);

      response = sender.sendReceive(payload);
      if (log.isDebugEnabled()) {
        log.debug("Response Message : " + response);
      }
    } catch (AxisFault axisFault) {
      log.error(axisFault.getMessage());
      throw new AxisFault("AxisFault while getting response :" + axisFault.getMessage(), axisFault);
    }
    return response;
  }
Example #6
0
 public JaggeryApplicationUploaderClient(String backEndUrl, String sessionCookie)
     throws AxisFault {
   String endPoint = backEndUrl + serviceName;
   try {
     jaggeryAppAdminStub = new JaggeryAppAdminStub(endPoint);
     AuthenticateStub.authenticateStub(sessionCookie, jaggeryAppAdminStub);
   } catch (AxisFault axisFault) {
     log.error("JaggeryAppAdminStub Initialization fail " + axisFault.getMessage());
     throw new AxisFault("JaggeryAppAdminStub Initialization fail " + axisFault.getMessage());
   }
 }
Example #7
0
 @Test(
     groups = {"wso2.esb"},
     description = "Creating SOAP1.1 fault messages as Response false")
 public void testSOAP11FaultAttributeResponseFalse() throws AxisFault {
   OMElement response;
   try {
     response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), null, "WSO2");
     fail("This query must throw an exception.");
   } catch (AxisFault expected) {
     log.info("Test passed with Fault Message : " + expected.getMessage());
     assertEquals(expected.getMessage(), "Read timed out", "Message mismatched");
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see com.google.code.magja.service.product.ProductAttributeRemoteService#
   * getOptions (com.google.code.magja.model.product.ProductAttribute)
   */
  @Override
  public void getOptions(ProductAttribute productAttribute) throws ServiceException {

    if (productAttribute.getId() == null && productAttribute.getCode() == null)
      throw new ServiceException("The id or the code of the attribute must have some value.");

    List<Map<String, Object>> options;
    try {
      options =
          (List<Map<String, Object>>)
              soapClient.call(
                  ResourcePath.ProductAttributeOptions,
                  (productAttribute.getId() != null
                      ? productAttribute.getId()
                      : productAttribute.getCode()));
    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (options != null) {
      for (Map<String, Object> option : options) {
        if (!"".equals((String) option.get("label"))) {
          if (productAttribute.getOptions() == null)
            productAttribute.setOptions(new HashMap<Integer, String>());
          productAttribute
              .getOptions()
              .put(new Integer((String) option.get("value")), (String) option.get("label"));
        }
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @seecom.google.code.magja.service.product.ProductAttributeRemoteService#
   * addOptions( com.google.code.magja.model.product.ProductAttribute ,
   * Map<Integer, String>)
   */
  @Override
  public void saveOptions(
      ProductAttribute productAttribute, Map<Integer, String> productAttributeOptions)
      throws ServiceException {
    // if has options, include this too
    if (productAttributeOptions != null) {
      if (!productAttributeOptions.isEmpty()) {
        String[] options = new String[productAttributeOptions.size()];
        int i = 0;
        for (Map.Entry<Integer, String> option : productAttributeOptions.entrySet())
          options[i++] = option.getValue();

        List<Object> params = new LinkedList<Object>();
        params.add(productAttribute.getId());
        params.add(options);

        try {
          if (!(Boolean) soapClient.call(ResourcePath.ProductAttributeAddOptions, params))
            throw new ServiceException(
                "The product attribute was saved, but had error " + "on save the options for that");
        } catch (AxisFault e) {
          if (debug) e.printStackTrace();
          throw new ServiceException(e.getMessage());
        }
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see com.google.code.magja.service.product.ProductAttributeRemoteService#
   * listByAttributeSet
   * (com.google.code.magja.model.product.ProductAttributeSet)
   */
  @Override
  public List<ProductAttribute> listByAttributeSet(ProductAttributeSet set)
      throws ServiceException {

    List<ProductAttribute> results = new ArrayList<ProductAttribute>();

    List<Map<String, Object>> prd_attributes = null;
    try {
      prd_attributes =
          (List<Map<String, Object>>)
              soapClient.call(ResourcePath.ProductAttributeList, set.getId());
    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (prd_attributes == null) return results;

    for (Map<String, Object> att : prd_attributes) {
      ProductAttribute prd_attribute = new ProductAttribute();
      for (Map.Entry<String, Object> attribute : att.entrySet()) {
        if (!attribute.getKey().equals("scope"))
          prd_attribute.set(attribute.getKey(), attribute.getValue());
      }

      prd_attribute.setScope(ProductAttribute.Scope.getByName((String) att.get("scope")));

      results.add(prd_attribute);
    }

    return results;
  }
  public ManageGenericArtifactServiceClient(ServletConfig config, HttpSession session)
      throws RegistryException {

    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
    ConfigurationContext configContext =
        (ConfigurationContext)
            config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    epr = backendServerURL + "ManageGenericArtifactService";

    try {
      stub = new ManageGenericArtifactServiceStub(configContext, epr);

      ServiceClient client = stub._getServiceClient();
      Options option = client.getOptions();
      option.setManageSession(true);
      option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

    } catch (AxisFault axisFault) {
      String msg =
          "Failed to initiate ManageGenericArtifactServiceClient. " + axisFault.getMessage();
      log.error(msg, axisFault);
      throw new RegistryException(msg, axisFault);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see com.google.code.magja.service.product.ProductAttributeRemoteService#
   * listAllProductAttributeSet()
   */
  @Override
  public List<ProductAttributeSet> listAllProductAttributeSet() throws ServiceException {

    List<ProductAttributeSet> resultList = new ArrayList<ProductAttributeSet>();

    List<Map<String, Object>> attSetList;
    try {
      attSetList =
          (List<Map<String, Object>>) soapClient.call(ResourcePath.ProductAttributeSetList, "");
    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (attSetList == null) return resultList;

    for (Map<String, Object> att : attSetList) {
      ProductAttributeSet set = new ProductAttributeSet();
      for (Map.Entry<String, Object> attribute : att.entrySet())
        set.set(attribute.getKey(), attribute.getValue());
      resultList.add(set);
    }

    return resultList;
  }
Example #13
0
  public void processEngageToService(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    Map<String, AxisModule> modules = configContext.getAxisConfiguration().getModules();

    req.getSession().setAttribute(Constants.MODULE_MAP, modules);
    populateSessionInformation(req);

    String moduleName = req.getParameter("modules");

    req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
    req.getSession().setAttribute("modules", null);

    String serviceName = req.getParameter("axisService");

    req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);

    if ((serviceName != null) && (moduleName != null)) {
      try {
        configContext
            .getAxisConfiguration()
            .getService(serviceName)
            .engageModule(configContext.getAxisConfiguration().getModule(moduleName));
        req.getSession()
            .setAttribute(
                Constants.ENGAGE_STATUS,
                moduleName + " module engaged to the service successfully");
      } catch (AxisFault axisFault) {
        req.getSession().setAttribute(Constants.ENGAGE_STATUS, axisFault.getMessage());
      }
    }

    req.getSession().setAttribute("axisService", null);
    renderView(ENGAGING_MODULE_TO_SERVICE_JSP_NAME, req, res);
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.google.code.magja.service.product.ProductAttributeRemoteService#save(
   * com.google.code.magja.model.product.ProductAttribute)
   */
  @Override
  public void save(ProductAttribute productAttribute) throws ServiceException {
    if (productAttribute.getId() != null || exists(productAttribute.getCode()))
      throw new ServiceException(
          productAttribute.getCode()
              + " exists already. Not allowed to update product attributes yet");

    Integer id = null;
    try {
      id =
          Integer.parseInt(
              (String)
                  soapClient.call(
                      ResourcePath.ProductAttributeCreate, productAttribute.serializeToApi()));
    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (id == null) throw new ServiceException("Error on save product attribute");

    productAttribute.setId(id);

    // if has options, include this too
    if (productAttribute.getOptions() != null) {
      if (!productAttribute.getOptions().isEmpty()) {
        String[] options = new String[productAttribute.getOptions().size()];
        int i = 0;
        for (Map.Entry<Integer, String> option : productAttribute.getOptions().entrySet())
          options[i++] = option.getValue();

        List<Object> params = new LinkedList<Object>();
        params.add(productAttribute.getId());
        params.add(options);

        try {
          if (!(Boolean) soapClient.call(ResourcePath.ProductAttributeAddOptions, params))
            throw new ServiceException(
                "The product attribute was saved, but had error " + "on save the options for that");
        } catch (AxisFault e) {
          if (debug) e.printStackTrace();
          throw new ServiceException(e.getMessage());
        }
      }
    }
  }
 private void setRegistry() throws DeploymentException {
   Parameter param = new Parameter(WSO2Constants.CONFIG_SYSTEM_REGISTRY_INSTANCE, registry);
   try {
     axisConfig.addParameter(param);
   } catch (AxisFault axisFault) {
     throw new DeploymentException(axisFault.getMessage(), axisFault);
   }
 }
 private void setUserRealm() throws DeploymentException {
   Parameter param = new Parameter(WSO2Constants.USER_REALM_INSTANCE, registry.getUserRealm());
   try {
     axisConfig.addParameter(param);
   } catch (AxisFault axisFault) {
     throw new DeploymentException(axisFault.getMessage(), axisFault);
   }
 }
  /*
   *  (non-Javadoc)
   * @see org.apache.axis2.jaxws.core.controller.InvocationController#invokeAsync(org.apache.axis2.jaxws.core.InvocationContext)
   */
  public Response doInvokeAsync(MessageContext request) {
    // We need the qname of the operation being invoked to know which
    // AxisOperation the OperationClient should be based on.
    // Note that the OperationDesc is only set through use of the Proxy. Dispatch
    // clients do not use operations, so the operationDesc will be null.  In this
    // case an anonymous AxisService with anoymouns AxisOperations for the supported
    // MEPs will be created; and it is that anonymous operation name which needs to
    // be specified
    QName operationName = getOperationNameToUse(request, ServiceClient.ANON_OUT_IN_OP);

    // TODO: Will the ServiceClient stick around on the InvocationContext
    // or will we need some other mechanism of creating this?
    // Try to create an OperationClient from the passed in ServiceClient
    InvocationContext ic = request.getInvocationContext();
    ServiceClient svcClient = ic.getServiceClient();
    OperationClient opClient = createOperationClient(svcClient, operationName);

    initOperationClient(opClient, request);

    // Setup the client so that it knows whether the underlying call to
    // Axis2 knows whether or not to start a listening port for an
    // asynchronous response.
    Boolean useAsyncMep = (Boolean) request.getProperty(Constants.USE_ASYNC_MEP);
    if ((useAsyncMep != null && useAsyncMep.booleanValue())
        || opClient.getOptions().isUseSeparateListener()) {
      configureAsyncListener(opClient);
    } else {
      if (log.isDebugEnabled()) {
        log.debug(
            "Asynchronous message exchange not enabled.  The invocation will be synchronous.");
      }
    }

    AsyncResponse resp = ic.getAsyncResponseListener();
    PollingFuture pf = new PollingFuture(ic);
    opClient.setCallback(pf);

    org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();
    try {
      execute(opClient, false, axisRequestMsgCtx);
    } catch (AxisFault af) {
      if (log.isDebugEnabled()) {
        log.debug(
            axisRequestMsgCtx.getLogIDString()
                + " AxisFault received from client: "
                + af.getMessage());
      }
      /*
       * Save the exception on the callback.  The client will learn about the error when they try to
       * retrieve the async results via the Response.get().  "Errors that occur during the invocation
       * are reported via an exception when the client attempts to retrieve the results of the operation."
       * -- JAXWS 4.3.3
       */
      pf.onError(af);
    }

    return resp;
  }
 public SAMLSSOConfigServiceClient(String backEndUrl, String userName, String password)
     throws RemoteException {
   this.endPoint = backEndUrl + serviceName;
   try {
     identitySAMLSSOConfigServiceStub = new IdentitySAMLSSOConfigServiceStub(endPoint);
   } catch (AxisFault axisFault) {
     log.error("Error on initializing stub : " + axisFault.getMessage());
     throw new RemoteException("Error on initializing stub : ", axisFault);
   }
   AuthenticateStub.authenticateStub(userName, password, identitySAMLSSOConfigServiceStub);
 }
Example #19
0
  /**
   * Function to send getUserInfo request to PM web service
   *
   * @param userid
   * @param password
   * @param projectID
   * @param project
   * @param demo Flag to indicate if we are in demo mode
   * @return A String containing the PM web service response
   */
  public String getUserInfo(
      String userid,
      PasswordType password,
      String projectURL,
      String project,
      boolean demo,
      String pid)
      throws Exception {
    String response = null;
    try {
      GetUseridsRequestMessage reqMsg = new GetUseridsRequestMessage(userid, password, project);

      RoleType userConfig = new RoleType();
      // userConfig.getProject().add(project);
      userConfig.setProjectId(pid);
      String getUserInfoRequestString = null;
      if (demo) {
        setUserInfo(getPMDemoString());
        System.setProperty("user", UserInfoBean.getInstance().getUserName()); // $NON-NLS-1$
        System.setProperty("pass", UserInfoBean.getInstance().getUserPassword()); // $NON-NLS-1$
      } else {
        getUserInfoRequestString = reqMsg.doBuildXML(userConfig);
        MessageUtil.getInstance()
            .setRequest("URL: " + projectURL + "getServices" + "\n" + getUserInfoRequestString);
        // log.info("PM request: /n"+getUserInfoRequestString);
        if (System.getProperty("webServiceMethod").equals("SOAP")) { // $NON-NLS-1$ //$NON-NLS-2$
          response =
              sendSOAP(
                  new EndpointReference(projectURL),
                  getUserInfoRequestString,
                  "http://rpdr.partners.org/GetUserConfiguration",
                  "GetUserConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$
        } else {
          response =
              sendREST(
                  new EndpointReference(projectURL + "getServices"),
                  getUserInfoRequestString); //$NON-NLS-1$
        }
        if (response == null) {
          log.info("no pm response received"); // $NON-NLS-1$
          return "error";
        }
        MessageUtil.getInstance()
            .setResponse("URL: " + projectURL + "getServices" + "\n" + response);
      }
    } catch (AxisFault e) {
      log.error(e.getMessage());
      setMsg(Messages.getString("LoginHelper.PMUnavailable")); // $NON-NLS-1$
    } catch (Exception e) {
      log.error(e.getMessage());
      setMsg(e.getMessage());
    }
    return response;
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.google.code.magja.service.product.ProductAttributeRemoteService#delete
   * (java.lang.String)
   */
  @Override
  public void delete(String attributeName) throws ServiceException {

    try {
      if (!(Boolean) soapClient.call(ResourcePath.ProductAttributeDelete, attributeName))
        throw new ServiceException("Error deleting product attribute.");
    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }
  }
  /** {@inheritDoc} */
  public SynapseConfiguration createSynapseConfiguration() {

    String synapseXMLLocation = serverConfigurationInformation.getSynapseXMLLocation();
    Properties properties = SynapsePropertiesLoader.loadSynapseProperties();
    if (serverConfigurationInformation.getResolveRoot() != null) {
      properties.put(
          SynapseConstants.RESOLVE_ROOT, serverConfigurationInformation.getResolveRoot());
    }

    if (serverConfigurationInformation.getSynapseHome() != null) {
      properties.put(
          SynapseConstants.SYNAPSE_HOME, serverConfigurationInformation.getSynapseHome());
    }

    if (synapseXMLLocation != null) {
      synapseConfiguration =
          SynapseConfigurationBuilder.getConfiguration(synapseXMLLocation, properties);
    } else {
      log.warn(
          "System property or init-parameter '"
              + SynapseConstants.SYNAPSE_XML
              + "' is not specified. Using default configuration..");
      synapseConfiguration = SynapseConfigurationBuilder.getDefaultConfiguration();
    }

    Enumeration keys = properties.keys();
    while (keys.hasMoreElements()) {
      String key = (String) keys.nextElement();
      synapseConfiguration.setProperty(key, properties.getProperty(key));
    }

    // Set the Axis2 ConfigurationContext to the SynapseConfiguration
    synapseConfiguration.setAxisConfiguration(configurationContext.getAxisConfiguration());
    MessageContextCreatorForAxis2.setSynConfig(synapseConfiguration);

    // set the Synapse configuration into the Axis2 configuration
    Parameter synapseConfigurationParameter =
        new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration);
    try {
      configurationContext.getAxisConfiguration().addParameter(synapseConfigurationParameter);
    } catch (AxisFault e) {
      handleFatal(
          "Could not set parameters '"
              + SynapseConstants.SYNAPSE_CONFIG
              + "' to the Axis2 configuration : "
              + e.getMessage(),
          e);
    }

    addServerIPAndHostEntries();

    return synapseConfiguration;
  }
  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;
  }
 private static void setHostName(AxisConfiguration axisConfig) throws DeploymentException {
   try {
     String hostName =
         CarbonCoreDataHolder.getInstance()
             .getServerConfigurationService()
             .getFirstProperty("HostName");
     if (hostName != null) {
       Parameter param = ParameterUtil.createParameter(HOST_ADDRESS, hostName);
       axisConfig.addParameter(param);
     }
   } catch (AxisFault axisFault) {
     throw new DeploymentException(axisFault.getMessage(), axisFault);
   }
 }
  public String LoginAs(String userName, String password, String host) {
    try {
      String log = c.login("admin", "admin", "localhost");
      System.out.println(log);
      sessionString = log;
      return log;
    } catch (AxisFault e) {
      System.out.println(e.getMessage());
    } catch (Exception e) {
      System.out.println("re " + e.getMessage());
    }

    return "error";
  }
Example #25
0
  public SourceHandler(SourceConfiguration sourceConfiguration) {
    this.sourceConfiguration = sourceConfiguration;
    this.metrics = sourceConfiguration.getMetrics();

    try {
      Scheme scheme = sourceConfiguration.getScheme();
      if (!scheme.isSSL()) {
        this.latencyView = new LatencyView(scheme.isSSL());
      } else {
        this.s2sLatencyView = new LatencyView(scheme.isSSL());
      }
    } catch (AxisFault e) {
      log.error(e.getMessage(), e);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @seecom.google.code.magja.service.product.ProductAttributeRemoteService#
   * getByCode(String)
   */
  public ProductAttribute getByCode(String code) throws ServiceException {

    Map<String, Object> remote_result = null;
    try {
      remote_result =
          (Map<String, Object>) soapClient.call(ResourcePath.ProductAttributeInfo, code);

    } catch (AxisFault e) {
      if (debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (remote_result == null) return null;
    else return buildProductAttribute(remote_result);
  }
Example #27
0
  public void processListOperations(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    Map<String, AxisModule> modules = configContext.getAxisConfiguration().getModules();

    req.getSession().setAttribute(Constants.MODULE_MAP, modules);

    String moduleName = req.getParameter("modules");

    req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
    req.getSession().setAttribute("modules", null);

    String serviceName = req.getParameter("axisService");

    if (serviceName != null) {
      req.getSession().setAttribute("service", serviceName);
    } else {
      serviceName = (String) req.getSession().getAttribute("service");
    }

    req.getSession()
        .setAttribute(
            Constants.OPERATION_MAP,
            configContext.getAxisConfiguration().getService(serviceName).getOperations());
    req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);

    String operationName = req.getParameter("axisOperation");

    if ((serviceName != null) && (moduleName != null) && (operationName != null)) {
      try {
        AxisOperation od =
            configContext
                .getAxisConfiguration()
                .getService(serviceName)
                .getOperation(new QName(operationName));

        od.engageModule(configContext.getAxisConfiguration().getModule(moduleName));
        req.getSession()
            .setAttribute(
                Constants.ENGAGE_STATUS,
                moduleName + " module engaged to the operation successfully");
      } catch (AxisFault axisFault) {
        req.getSession().setAttribute(Constants.ENGAGE_STATUS, axisFault.getMessage());
      }
    }

    req.getSession().setAttribute("operation", null);
    renderView(ENGAGE_TO_OPERATION_JSP_NAME, req, res);
  }
Example #28
0
  @Test(
      groups = {"wso2.cep"},
      description = "Testing HTTP publisher connection",
      expectedExceptions = AxisFault.class)
  public void testConnection() throws AxisFault {
    BasicOutputAdapterPropertyDto url = new BasicOutputAdapterPropertyDto();
    url.setKey("http.url");
    url.setValue("http://localhost:9763/GenericLogService/log");
    url.set_static(false);
    BasicOutputAdapterPropertyDto username = new BasicOutputAdapterPropertyDto();
    username.setKey("http.username");
    username.setValue("");
    username.set_static(false);
    BasicOutputAdapterPropertyDto password = new BasicOutputAdapterPropertyDto();
    password.setKey("http.password");
    password.setValue("");
    password.set_static(false);
    BasicOutputAdapterPropertyDto headers = new BasicOutputAdapterPropertyDto();
    headers.setKey("http.headers");
    headers.setValue("Content-Type: application/json");
    headers.set_static(false);
    BasicOutputAdapterPropertyDto proxyHost = new BasicOutputAdapterPropertyDto();
    proxyHost.setKey("http.proxy.host");
    proxyHost.setValue("");
    proxyHost.set_static(false);
    BasicOutputAdapterPropertyDto proxyPort = new BasicOutputAdapterPropertyDto();
    proxyPort.setKey("http.proxy.port");
    proxyPort.setValue("");
    proxyPort.set_static(false);
    BasicOutputAdapterPropertyDto clientMethod = new BasicOutputAdapterPropertyDto();
    clientMethod.setKey("http.proxy.port");
    clientMethod.setValue("");
    clientMethod.set_static(true);
    BasicOutputAdapterPropertyDto[] outputPropertyConfiguration =
        new BasicOutputAdapterPropertyDto[] {
          url, username, password, headers, proxyHost, proxyPort, clientMethod
        };

    try {
      eventPublisherAdminServiceClient.testConnection(
          "httpJson", "http", outputPropertyConfiguration, "json");
    } catch (AxisFault e) {
      throw new AxisFault(e.getMessage(), e);
    } catch (RemoteException e) {
      log.error("Exception thrown: " + e.getMessage(), e);
      Assert.fail("Exception: " + e.getMessage());
    }
  }
 @SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
 @Test(
     groups = "wso2.esb",
     description =
         "Test Error response created via makefault is never sent to the client "
             + "when the error connection timeout occurs by closing the TCP mon connection")
 public void testMakeFaultForConnectionTimeoutResponse() {
   try {
     axis2Client.sendSimpleStockQuoteRequest(
         getProxyServiceURLHttp("simpleStockPassthroug"), null, "WSO2");
   } catch (AxisFault axisFault) {
     /** since we are making a soap fault in the configuration axis2 client receives axis fault. */
     String axisFaultMessage = axisFault.getMessage();
     assertTrue(axisFaultMessage.contains("101508"));
   }
 }
  public LocalEntryDeployer(String ip, String port) throws EmailMonitorServiceException {
    String endPoint =
        EmailMonitorConstants.PROTOCOL
            + ip
            + ":"
            + port
            + EmailMonitorConstants.SERVICES
            + EmailMonitorConstants.LOCAL_ENTRY_ADMIN_SERVICE;

    try {
      stub = new LocalEntryAdminServiceStub(endPoint);
    } catch (AxisFault axisFault) {
      logger.error(axisFault.getMessage());
      throw new EmailMonitorServiceException("Error when creating LocalEntryDeployer", axisFault);
    }
  }