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;
  }
Beispiel #2
0
  /**
   * This utility method creates a vector with results, after an asynchrone web service has been
   * called. Because we need a Vector<DBColumn> to
   *
   * @param event WebServiceEvent, the event which has been given after a Web-Service call.
   * @return result ArrayList<DBColumn>, the vector has no elements if no content in the
   *     WebServiceEvent is given
   */
  public static ArrayList<DBColumn> createResultList(WebServiceEvent event) {

    // SOAP envelope -> create a readable OMElement
    OMElement element = event.getServiceResult();

    Iterator<OMElement> it = element.getChildrenWithLocalName("column");
    // Object[] javaTypes = {DBColumn.class};
    ArrayList<DBColumn> results = new ArrayList<DBColumn>();
    ObjectSupplier objectSupplier = new AxisService().getObjectSupplier();

    // get all DBColumn deserialized
    OMElement oneDBColumn;
    while (it.hasNext()) {
      oneDBColumn = (it.next());

      DBColumn workingColumn;
      try {
        workingColumn =
            (DBColumn) BeanUtil.deserialize(DBColumn.class, oneDBColumn, objectSupplier, "column");
        results.add(workingColumn);
      } catch (AxisFault ex) {
        ex.printStackTrace();
      }
    }
    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;
  }
  public static void main(String[] args) {

    String testingURL = "http://localhost:8080/axis2/services/springService";

    RPCServiceClient serviceClient;
    try {
      serviceClient = new RPCServiceClient();
      Options options = serviceClient.getOptions();

      EndpointReference targetEPR = new EndpointReference(testingURL);
      options.setTo(targetEPR);

      //	        The parameters which used for invoke the service
      //	        Object[] entryArgs = new Object[] {1, 2};

      //	        The return type
      Class[] classes = new Class[] {float.class};

      //	        The namespace and services.
      QName qname = new QName("http://test.webservice.meme.com", "toString");
      Object[] result =
          serviceClient.invokeBlocking(qname, new Object[] {null}, new Class[] {String.class});
      System.out.println(result[0]);

      //	        System.out.println(result);

    } catch (AxisFault e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  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#
   * 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 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;
  }
Beispiel #8
0
 public void getMenus(String menu) {
   Object[] params = new Object[] {menu};
   Class[] retTypes = new Class[] {sf.file.Menus.class};
   try {
     String method = "getMenus";
     if (menu != null && !menu.equals("")) method = "getMenuByName";
     Object[] response = _service.callServiceAccounting(method, params, retTypes);
     sf.file.Menus item = (sf.file.Menus) response[0];
     if (item == null) return;
     if (item.getMenus() == null) return;
     int count = item.getMenus().length;
     list = new ArrayList<Menus>();
     for (int i = 0; i < count; i++) {
       sf.file.Menus prheader = item.getMenus()[i];
       if (prheader == null) continue;
       Menus _prheader = new Menus();
       _prheader.setNo(i + 1);
       _prheader.setMenuname(prheader.getMenuname());
       _prheader.setRecstatus(prheader.getRecstatus());
       if (null != _prheader) {
         list.add(_prheader);
       }
     }
   } catch (AxisFault e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Beispiel #9
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)
   *
   * @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#
   * 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)
   *
   * @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;
  }
 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);
   }
 }
Beispiel #14
0
 private void init() {
   try {
     _service = new Service(Service.ACCOUNTING_SERVICE_URL);
   } catch (AxisFault e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 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);
   }
 }
  /*
   *  (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 void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext)
      throws org.apache.axis2.AxisFault {

    try {

      // get the implementation class for the Web Service
      Object obj = getTheImplementationObject(msgContext);

      MultitenancyThrottlingServiceSkeletonInterface skel =
          (MultitenancyThrottlingServiceSkeletonInterface) obj;
      // Out Envelop
      org.apache.axiom.soap.SOAPEnvelope envelope = null;
      // Find the axisOperation that has been set by the Dispatch phase.
      org.apache.axis2.description.AxisOperation op =
          msgContext.getOperationContext().getAxisOperation();
      if (op == null) {
        throw new org.apache.axis2.AxisFault(
            "Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider");
      }

      java.lang.String methodName;
      if ((op.getName() != null)
          && ((methodName =
                  org.apache.axis2.util.JavaUtils.xmlNameToJavaIdentifier(
                      op.getName().getLocalPart()))
              != null)) {

        if ("executeThrottlingRules".equals(methodName)) {

          // doc style
          org.wso2.carbon.throttling.manager.services.ExecuteThrottlingRules wrappedParam =
              (org.wso2.carbon.throttling.manager.services.ExecuteThrottlingRules)
                  fromOM(
                      msgContext.getEnvelope().getBody().getFirstElement(),
                      org.wso2.carbon.throttling.manager.services.ExecuteThrottlingRules.class,
                      getEnvelopeNamespaces(msgContext.getEnvelope()));

          skel.executeThrottlingRules(wrappedParam);

          envelope = getSOAPFactory(msgContext).getDefaultEnvelope();

        } else {
          throw new java.lang.RuntimeException("method not found");
        }
      }
    } catch (MultitenancyThrottlingServiceExceptionException e) {
      msgContext.setProperty(
          org.apache.axis2.Constants.FAULT_NAME, "MultitenancyThrottlingServiceException");
      org.apache.axis2.AxisFault f = createAxisFault(e);
      if (e.getFaultMessage() != null) {
        f.setDetail(toOM(e.getFaultMessage(), false));
      }
      throw f;
    } catch (java.lang.Exception e) {
      throw org.apache.axis2.AxisFault.makeFault(e);
    }
  }
Beispiel #18
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);
  }
 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);
 }
Beispiel #20
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());
   }
 }
  /*
   * (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());
    }
  }
 private void init() {
   maps = new HashMap<String, String>();
   assignFilterMap();
   maps1 = new HashMap<String, sf.purchasing.PRHeader>();
   try {
     _service = new Service(Service.PURCHASING_SERVICE_URL);
   } catch (AxisFault e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Beispiel #23
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;
  }
  /** {@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;
  }
  /**
   * Invalid service referred
   *
   * @throws Exception
   */
  @Test(groups = "wso2.esb", description = "- Custom proxy -Fault sequence existing fault sequence")
  public void testCustomProxyFaultExistingFaultSequence() throws Exception {

    try {
      axis2Client.sendSimpleStockQuoteRequest(
          getProxyServiceURLHttp("StockQuoteProxyFour"), null, "WSO2");
      fail();
    } catch (AxisFault axisFault) {
      assertTrue(
          axisFault.getReason().contains("Fault sequence invoked"),
          "Fault: value 'reason' mismatched");
    }
  }
  /**
   * TODO get server
   *
   * @return
   */
  public UserManagementServiceStub getServer() {

    UserManagementServiceStub server = null;
    try {
      server =
          new UserManagementServiceStub(
              HtmlCommonUtil.getWSContext(), WebServiceConfigurator.getUrlOfPoiReviewWrite());
    } catch (AxisFault e) {
      e.getCause();
    }

    return server;
  }
Beispiel #27
0
 /** Creates an AxisFault. */
 public static AxisFault createAxisFault(Exception e) {
   AxisFault fault;
   Throwable cause = e.getCause();
   if (cause != null) {
     fault = new AxisFault(e.getMessage(), cause);
   } else {
     fault = new AxisFault(e.getMessage());
   }
   fault.setDetail(DataServiceFault.extractFaultMessage(e));
   fault.setFaultCode(
       new QName(DBConstants.WSO2_DS_NAMESPACE, DataServiceFault.extractFaultCode(e)));
   return fault;
 }
Beispiel #28
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");
   }
 }
  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";
  }
  public void testSample() throws Exception {
    getStringResultOfTest(StockQuoteClient.executeTestClient());
    getStringResultOfTest(StockQuoteClient.executeTestClient());
    getStringResultOfTest(StockQuoteClient.executeTestClient());
    String resultString = getStringResultOfTest(StockQuoteClient.executeTestClient());
    assertXpathExists("ns:getQuoteResponse", resultString);
    assertXpathExists("ns:getQuoteResponse/ns:return", resultString);

    try {
      getStringResultOfTest(StockQuoteClient.executeTestClient());
    } catch (AxisFault f) {
      assertEquals("**Access Denied**", f.getReason());
    }
  }