Example #1
0
 /** Creates OMElement using error details. */
 public static OMElement createDSFaultOM(String msg) {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMElement ele =
       fac.createOMElement(new QName(DBConstants.WSO2_DS_NAMESPACE, DBConstants.DS_FAULT_ELEMENT));
   ele.setText(msg);
   return ele;
 }
Example #2
0
 public OMElement buildXML() {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMElement confEl = fac.createOMElement("config", null);
   if (this.getId() != null) {
     confEl.addAttribute("id", this.getId(), null);
   }
   /* build properties */
   Iterator<Property> iterator = this.getProperties().iterator();
   while (iterator.hasNext()) {
     Property property = iterator.next();
     if (this.isUseSecretAliasForPassword()
         && (property.getName().equals(RDBMS.PASSWORD)
             || property.getName().equals(RDBMS_OLD.PASSWORD)
             || property.getName().equals(GSpread.PASSWORD)
             || property.getName().equals(JNDI.PASSWORD))) {
       OMFactory factory = OMAbstractFactory.getOMFactory();
       OMElement propEl = factory.createOMElement("property", null);
       propEl.addAttribute("name", property.getName(), null);
       propEl.addAttribute("svns:secretAlias", (String) property.getValue(), null);
       confEl.addChild(propEl);
     } else {
       if (property.buildXML() != null) {
         confEl.addChild(property.buildXML());
       }
     }
   }
   return confEl;
 }
  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;
  }
  @Override
  public void connect(MessageContext messageContext) throws ConnectException {
    String providerUrl = LDAPUtils.lookupContextParams(messageContext, LDAPConstants.PROVIDER_URL);
    String dn = (String) getParameter(messageContext, "dn");
    String password = (String) getParameter(messageContext, "password");

    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace(LDAPConstants.CONNECTOR_NAMESPACE, "ns");
    OMElement result = factory.createOMElement("result", ns);
    OMElement message = factory.createOMElement("message", ns);

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, providerUrl);
    env.put(Context.SECURITY_PRINCIPAL, dn);
    env.put(Context.SECURITY_CREDENTIALS, password);

    org.apache.axis2.context.MessageContext axis2MessageContext =
        ((Axis2MessageContext) messageContext).getAxis2MessageContext();

    boolean logged = false;
    DirContext ctx = null;
    try {
      ctx = new InitialDirContext(env);
      message.setText("Success");
      result.addChild(message);
      LDAPUtils.preparePayload(messageContext, result);
    } catch (NamingException e) {
      message.setText("Fail");
      result.addChild(message);
      LDAPUtils.preparePayload(messageContext, result);
    }
  }
 private static void addPropertyElements(
     OMFactory factory,
     OMElement parent,
     String className,
     String description,
     Map<String, String> properties) {
   if (className != null) {
     parent.addAttribute(UserCoreConstants.RealmConfig.ATTR_NAME_CLASS, className, null);
   }
   if (description != null) {
     parent.addAttribute(UserCoreConstants.RealmConfig.CLASS_DESCRIPTION, description, null);
   }
   Iterator<Map.Entry<String, String>> ite = properties.entrySet().iterator();
   while (ite.hasNext()) {
     Map.Entry<String, String> entry = ite.next();
     String name = entry.getKey();
     String value = entry.getValue();
     OMElement propElem =
         factory.createOMElement(new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_PROPERTY));
     OMAttribute propAttr =
         factory.createOMAttribute(UserCoreConstants.RealmConfig.ATTR_NAME_PROP_NAME, null, name);
     propElem.addAttribute(propAttr);
     propElem.setText(value);
     parent.addChild(propElem);
   }
 }
  OMElement buildReport(Message m) throws ServletException {
    if (!verifyTables(m)) {
      throw new ServletException("Missing Table");
    }

    System.out.println(index(m));

    HashMap<String, HashMap<String, Object>> mm = m.toHashMap();

    OMElement report = omFactory.createOMElement(new QName("XdsEvsResult"));

    addParm(report, mm, "Test", "other", "Service");
    addParm(report, mm, "Date", "main", "Timestamp");
    addParm(report, mm, "Source", "http", "IP_address_From");

    OMElement ele = omFactory.createOMElement(new QName("Target"));
    ele.setText(localIPAddress());
    report.addChild(ele);

    addParm(report, mm, "Endpoint", "http", "URI_To");
    addParm(report, mm, "Result", "main", "Pass");
    addParm(report, mm, "LogEvent", "main", "MessageId");

    addParm(report, mm, "Error", "error", "Error");

    // System.out.println("errors are:\n" + mm.get("error"));

    return report;
  }
Example #7
0
  private OMElement getRSTTemplate() throws TrustException {
    OMFactory omFac = OMAbstractFactory.getOMFactory();
    OMElement element = omFac.createOMElement(SP11Constants.REQUEST_SECURITY_TOKEN_TEMPLATE);

    if (ClientConstants.SAML_TOKEN_TYPE_20.equals(tokenType)) {
      TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, element)
          .setText(RahasConstants.TOK_TYPE_SAML_20);
    } else if (ClientConstants.SAML_TOKEN_TYPE_11.equals(tokenType)) {
      TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, element)
          .setText(RahasConstants.TOK_TYPE_SAML_10);
    }

    if (ClientConstants.SUBJECT_CONFIRMATION_BEARER.equals(subjectConfirmationMethod)) {
      TrustUtil.createKeyTypeElement(
          RahasConstants.VERSION_05_02, element, RahasConstants.KEY_TYPE_BEARER);
    } else if (ClientConstants.SUBJECT_CONFIRMATION_HOLDER_OF_KEY.equals(
        subjectConfirmationMethod)) {
      TrustUtil.createKeyTypeElement(
          RahasConstants.VERSION_05_02, element, RahasConstants.KEY_TYPE_SYMM_KEY);
    }

    // request claims in the token.
    OMElement claimElement =
        TrustUtil.createClaims(RahasConstants.VERSION_05_02, element, claimDialect);
    // Populate the <Claims/> element with the <ClaimType/> elements
    addClaimType(claimElement, claimUris);

    return element;
  }
  /**
   * Contains the logic to create URITemplate XML Element from the swagger 2.0 resource.
   *
   * @param swaggerDocObject swagger document
   * @return URITemplate element.
   */
  private static List<OMElement> createURITemplateFromSwagger2(JsonObject swaggerDocObject) {

    List<OMElement> uriTemplates = new ArrayList<>();

    JsonObject paths = swaggerDocObject.get(SwaggerConstants.PATHS).getAsJsonObject();
    Set<Map.Entry<String, JsonElement>> pathSet = paths.entrySet();

    for (Map.Entry path : pathSet) {
      JsonObject urlPattern = ((JsonElement) path.getValue()).getAsJsonObject();
      String pathText = path.getKey().toString();
      Set<Map.Entry<String, JsonElement>> operationSet = urlPattern.entrySet();

      for (Map.Entry operationEntry : operationSet) {
        OMElement uriTemplateElement = factory.createOMElement(URI_TEMPLATE, namespace);
        OMElement urlPatternElement = factory.createOMElement(URL_PATTERN, namespace);
        OMElement httpVerbElement = factory.createOMElement(HTTP_VERB, namespace);
        OMElement authTypeElement = factory.createOMElement(AUTH_TYPE, namespace);

        urlPatternElement.setText(pathText);
        httpVerbElement.setText(operationEntry.getKey().toString());

        uriTemplateElement.addChild(urlPatternElement);
        uriTemplateElement.addChild(httpVerbElement);
        uriTemplateElement.addChild(authTypeElement);
        uriTemplates.add(uriTemplateElement);
      }
    }
    return uriTemplates;
  }
  private OMElement handleSLORequest(MessageContext messageContext, LogoutRequest logoutRequest) {

    // Get the session index from the SLORequest and remove the relevant session.
    String sessionIndex = logoutRequest.getSessionIndexes().get(0).getSessionIndex();

    String sessionId = CacheManager.getInstance().getSessionIndexMappingCache().get(sessionIndex);

    if (sessionId != null) {
      GatewayUtils.logWithRequestInfo(
          log,
          messageContext,
          String.format(
              "Found a session id (md5 : '%s')for the given session index in the SLO request: '%s'. Clearing the session",
              GatewayUtils.getMD5Hash(sessionId), sessionIndex));
      SessionStore.getInstance().removeSession(sessionId);
      CacheManager.getInstance().getSessionIndexMappingCache().remove(sessionIndex);
    } else {
      GatewayUtils.logWithRequestInfo(
          log,
          messageContext,
          String.format(
              "Couldn't find a session id for the given session index : '%s'", sessionIndex));
    }

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace("http://wso2.org/appm", "appm");
    OMElement payload = fac.createOMElement("SLOResponse", ns);

    OMElement errorMessage = fac.createOMElement("message", ns);
    errorMessage.setText("SLORequest has been successfully processed by WSO2 App Manager");

    payload.addChild(errorMessage);

    return payload;
  }
  /**
   * Retrieve all entries from service.
   *
   * @return All entries of type Entry from the service.
   * @exception FailureFaultException If an error communication with the service occurs.
   */
  public Entry[] retrieve() throws FailureFaultException {
    final String method = "retrieve";
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace namespace = factory.createOMNamespace(SERVICE, method);

    // Create a request
    OMElement request = factory.createOMElement("RetrieveRequest", namespace);

    // Configure connection
    Options options = new Options();
    options.setTo(new EndpointReference(url.toString()));
    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    options.setAction(method);

    // Create a client
    try {
      ServiceClient client = new ServiceClient();
      client.setOptions(options);

      // Try send request and receive response, could throw AxisFault
      OMElement response = client.sendReceive(request);

      // Debug
      printDebug("RESPONSE", response);

      // Parse and return result
      Entry[] result = XMLUtil.parseScores(response);
      return result;
    } catch (AxisFault e) {
      throw new FailureFaultException("Exception from service: ", e);
    }
  }
 public void addIds(
     String strOperation, String strParamName, MessageContext synCtx, SynapseLog synLog) {
   SOAPEnvelope envelope = synCtx.getEnvelope();
   OMFactory fac = OMAbstractFactory.getOMFactory();
   SOAPBody body = envelope.getBody();
   Iterator<OMElement> bodyChildElements = body.getChildrenWithLocalName(strOperation);
   if (bodyChildElements.hasNext()) {
     try {
       OMElement bodyElement = bodyChildElements.next();
       Iterator<OMElement> cElements = bodyElement.getChildElements();
       if (cElements != null && cElements.hasNext()) {
         cElements.next();
       }
       String strSobject = (String) ConnectorUtils.lookupTemplateParamater(synCtx, strParamName);
       OMElement sObjects = AXIOMUtil.stringToOM(strSobject);
       Iterator<OMElement> sObject = sObjects.getChildElements();
       OMNamespace omNsurn = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn");
       // Loops sObject
       while (sObject.hasNext()) {
         OMElement currentElement = sObject.next();
         OMElement newElement = fac.createOMElement("ids", omNsurn);
         // Add the fields
         newElement.addChild(fac.createOMText(currentElement.getText()));
         bodyElement.addChild(newElement);
       }
     } catch (Exception e) {
       synLog.error("Saleforce adaptor - error injecting sObjects to payload : " + e);
     }
   }
 }
Example #12
0
  public OMElement toOM() {

    OMFactory omFactory = OMAbstractFactory.getOMFactory();

    OMElement targetElement =
        omFactory.createOMElement(
            Constants.RULE_CONF_ELE_TARGET,
            Constants.RULE_CONF_NAMESPACE,
            Constants.RULE_CONF_NAMESPACE_PREFIX);
    if (this.xpath != null) {
      targetElement.addAttribute(Constants.RULE_CONF_ATTR_XPATH, this.xpath, null);
    }

    if (this.resultXpath != null) {
      targetElement.addAttribute(Constants.RULE_CONF_ATTR_RESULT_XPATH, this.resultXpath, null);
    }

    if (this.action != null) {
      targetElement.addAttribute(Constants.RULE_CONF_ATTR_ACTION, this.action, null);
    }

    if (this.value != null) {
      targetElement.setText(this.value);
    }

    if (this.prefixToNamespaceMap != null) {

      for (String prefix : this.prefixToNamespaceMap.keySet()) {

        String nsURI = this.prefixToNamespaceMap.get(prefix);
        targetElement.declareNamespace(nsURI, prefix);
      }
    }
    return targetElement;
  }
Example #13
0
 public static OMElement queryToOM(Query query) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement queryChild =
       factory.createOMElement(
           new QName(
               CEPConstants.CEP_CONF_NAMESPACE,
               CEPConstants.CEP_CONF_ELE_QUERY,
               CEPConstants.CEP_CONF_CEP_NAME_SPACE_PREFIX));
   Expression queryExpression = query.getExpression();
   String queryName = query.getName();
   OMElement queryIP = null;
   List<String> ipList = query.getIpList();
   for (String ip : ipList) {
     queryIP = factory.createOMElement(new QName(CEPConstants.CEP_CONF_QUERY_IP));
     queryIP.setText(ip);
     queryChild.addChild(queryIP);
   }
   queryChild.addAttribute(CEPConstants.CEP_CONF_ATTR_NAME, queryName, null);
   OMElement omQueryExpression = ExpressionHelper.expressionToOM(queryExpression);
   queryChild.addChild(omQueryExpression);
   if (query.getOutput() != null) {
     OMElement queryOutput = OutputHelper.outputToOM(query.getOutput());
     queryChild.addChild(queryOutput);
   }
   return queryChild;
 }
  public void doGet(HttpServletRequest req, HttpServletResponse res) {
    res.setContentType("application/download-xml-file");

    String messageId = req.getParameter("message");

    OMElement report = null;

    try {
      Message m = new Message(messageId);
      m.readMessage();

      report = buildReport(m);

    } catch (LoggerException e) {
      report = omFactory.createOMElement(new QName("NoReportAvailable"));
      report.setText(e.getMessage().replaceAll("<", "&lt;"));
    } catch (ServletException e) {
      report = omFactory.createOMElement(new QName("NoReportAvailable"));
      report.setText(e.getMessage().replaceAll("<", "&lt;"));
    }

    try {
      res.getWriter().write(report.toString());
    } catch (IOException e) {
    }
  }
Example #15
0
 /**
  * This method will check whether the text can be optimizable using IS_BINARY flag. If that is set
  * then we try to get the data handler.
  *
  * @param omContainer
  * @param textType
  * @return omNode
  */
 private OMNode createOMText(OMContainer omContainer, int textType) {
   if (dataHandlerReader != null && dataHandlerReader.isBinary()) {
     Object dataHandlerObject;
     if (dataHandlerReader.isDeferred()) {
       dataHandlerObject = dataHandlerReader.getDataHandlerProvider();
     } else {
       try {
         dataHandlerObject = dataHandlerReader.getDataHandler();
       } catch (XMLStreamException ex) {
         throw new OMException(ex);
       }
     }
     OMText text = omfactory.createOMText(dataHandlerObject, dataHandlerReader.isOptimized());
     String contentID = dataHandlerReader.getContentID();
     if (contentID != null) {
       text.setContentID(contentID);
     }
     omContainer.addChild(text);
     return text;
   } else {
     // Some parsers (like Woodstox) parse text nodes lazily and may throw a
     // RuntimeException in getText()
     String text;
     try {
       text = parser.getText();
     } catch (RuntimeException ex) {
       parserException = ex;
       throw ex;
     }
     return omfactory.createOMText(omContainer, text, textType);
   }
 }
 private OMElement createCustomQuoteRequest(String symbol) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMNamespace ns = factory.createOMNamespace("http://services.samples", "ns");
   OMElement chkPrice = factory.createOMElement("CheckPriceRequest", ns);
   OMElement code = factory.createOMElement("Code", ns);
   chkPrice.addChild(code);
   code.setText(symbol);
   return chkPrice;
 }
 private OMElement getTextElement(String content) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement textElement = factory.createOMElement(TEXT_ELEMENT);
   if (content == null) {
     content = "";
   }
   textElement.setText(content);
   return textElement;
 }
 private static OMElement createPayLoad() {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMNamespace omNs = fac.createOMNamespace("http://service.carbon.wso2.org", "ns1");
   OMElement method = fac.createOMElement("echoString", omNs);
   OMElement value = fac.createOMElement("s", omNs);
   value.addChild(fac.createOMText(value, "Hello World"));
   method.addChild(value);
   return method;
 }
Example #19
0
 private static OMElement getRSTTemplate() throws Exception {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMElement elem = fac.createOMElement(SP11Constants.REQUEST_SECURITY_TOKEN_TEMPLATE);
   TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, elem)
       .setText(RahasConstants.TOK_TYPE_SAML_10);
   TrustUtil.createKeyTypeElement(
       RahasConstants.VERSION_05_02, elem, RahasConstants.KEY_TYPE_SYMM_KEY);
   TrustUtil.createKeySizeElement(RahasConstants.VERSION_05_02, elem, 256);
   return elem;
 }
Example #20
0
  private static OMElement getPayload(String value) {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns =
        factory.createOMNamespace("http://sample05.policy.samples.rampart.apache.org", "ns1");
    OMElement elem = factory.createOMElement("echo", ns);
    OMElement childElem = factory.createOMElement("param0", null);
    childElem.setText(value);
    elem.addChild(childElem);

    return elem;
  }
  private OMElement createStandardSimpleRequest(String symbol) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getSimpleQuote", omNs);
    OMElement value1 = fac.createOMElement("symbol", omNs);

    value1.addChild(fac.createOMText(method, symbol));
    method.addChild(value1);

    return method;
  }
Example #22
0
  private static OMElement getPingOMBlock(String text) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
    OMElement pingElem = fac.createOMElement(ping, namespace);
    OMElement textElem = fac.createOMElement(Text, namespace);

    textElem.setText(text);
    pingElem.addChild(textElem);

    return pingElem;
  }
 public static OMElement CreatePayload() // this function create a message to send to server
     {
   OMFactory fac =
       OMAbstractFactory
           .getOMFactory(); // Create object(fac)from OM Factory this is used to create all the
                            // elements.
   OMNamespace omns =
       fac.createOMNamespace(
           "http://ws.wso2.org/dataservice",
           "b"); // creating namespace to assign to message, b =  namespace
   OMElement OP1 = fac.createOMElement("OP_Count", omns); // Operation name
   return OP1;
 }
  private OMElement createPayload() {

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
    OMElement rpcWrapEle = fac.createOMElement("echoMTOMtoBase64", omNs);
    OMElement data = fac.createOMElement("data", omNs);
    byte[] byteArray = new byte[] {13, 56, 65, 32, 12, 12, 7, 98};
    DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
    expectedTextData = new OMTextImpl(dataHandler, true, fac);
    data.addChild(expectedTextData);
    rpcWrapEle.addChild(data);
    return rpcWrapEle;
  }
Example #25
0
 public static OMElement wrapBoxCarringResponse(OMElement result) {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMElement wrapperElement =
       fac.createOMElement(
           new QName(
               DBConstants.WSO2_DS_NAMESPACE, DBConstants.DATA_SERVICE_RESPONSE_WRAPPER_ELEMENT));
   if (result != null) {
     wrapperElement.addChild(result);
   }
   OMDocument doc = fac.createOMDocument();
   doc.addChild(wrapperElement);
   return doc.getOMDocumentElement();
 }
  public final OMElement getParameters() {
    OMFactory omFactory = OMAbstractFactory.getOMFactory();

    OMElement parameters = omFactory.createOMElement("parameters", null);

    for (Map.Entry<Integer, Integer> e : this.users.entrySet()) {
      OMElement user = omFactory.createOMElement("user_item", null);
      user.addAttribute("id", e.getKey().toString(), null);
      user.addAttribute("version", e.getValue().toString(), null);

      parameters.addChild(user);
    }
    return parameters;
  }
  private static OMElement getPayload() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://service.esb.wso2.org", "ns");
    OMElement method = fac.createOMElement("add", omNs);
    OMElement value1 = fac.createOMElement("x", omNs);
    OMElement value2 = fac.createOMElement("y", omNs);

    value1.addChild(fac.createOMText(value1, "10"));
    value2.addChild(fac.createOMText(value2, "10"));
    method.addChild(value1);
    method.addChild(value2);

    return method;
  }
  public OMElement getCEPPublisher(OMElement request) throws XMLStreamException {
    request.build();
    request.detach();

    OMElement tenantId =
        request.getFirstChildWithName(
            new QName(
                ManagerServiceConstants.NAMESPACE, ManagerServiceConstants.ELEMENT_TENANT_ID));
    OMElement executionPlan =
        request.getFirstChildWithName(
            new QName(
                ManagerServiceConstants.NAMESPACE, ManagerServiceConstants.ELEMENT_EXEC_PLAN));
    OMElement requesterIp =
        request.getFirstChildWithName(
            new QName(
                ManagerServiceConstants.NAMESPACE, ManagerServiceConstants.ELEMENT_REQUESTER_IP));
    String key = getKey(executionPlan.getText(), tenantId.getText());
    log.info("CEP Publisher requested for  " + key);

    Set<Endpoint> endpointSet = cepPublishers.get(key);
    Endpoint selectedEndpoint = selectEndpoint(endpointSet, requesterIp.getText());
    OMElement response =
        factory.createOMElement(
            ManagerServiceConstants.ELEMENT_CEP_PUBLISHER_RESPONSE, OMNamespace);
    if (selectedEndpoint != null) {
      OMElement hostNameElement =
          factory.createOMElement(ManagerServiceConstants.ELEMENT_HOST_NAME, OMNamespace);
      OMElement portElement =
          factory.createOMElement(ManagerServiceConstants.ELEMENT_PORT, OMNamespace);

      OMText hostNameText = factory.createOMText(hostNameElement, selectedEndpoint.getHostName());
      OMText portText =
          factory.createOMText(portElement, Integer.toString(selectedEndpoint.getPort()));

      hostNameElement.addChild(hostNameText);
      portElement.addChild(portText);
      response.addChild(hostNameElement);
      response.addChild(portElement);
      log.info(
          "Returning CEP Publisher:"
              + selectedEndpoint.getHostName()
              + ":"
              + selectedEndpoint.getPort());
    } else {
      log.warn("No CEP publishers registered " + key);
    }

    return response;
  }
  @Test(
      groups = {"wso2.dss"},
      invocationCount = 5,
      dependsOnMethods = "testServiceDeployment")
  public void selectOperation() throws AxisFault, XPathExpressionException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://www.w3.org/2005/08/addressing", "ns1");
    OMElement payload = fac.createOMElement("getAllUsers", omNs);

    OMElement result = new AxisServiceClient().sendReceive(payload, serviceUrl, "getAllUsers");
    Assert.assertTrue(result.toString().contains("Will Smith"));
    Assert.assertTrue(result.toString().contains("Denzel Washington"));

    log.info("Service invocation success");
  }
Example #30
0
  private OMElement getPayload(String value) {
    OMFactory factory = null;
    OMNamespace ns = null;
    OMElement elem = null;
    OMElement childElem = null;

    factory = OMAbstractFactory.getOMFactory();
    ns = factory.createOMNamespace("http://echo.services.core.carbon.wso2.org", "ns");
    elem = factory.createOMElement("echoString", ns);
    childElem = factory.createOMElement("in", null);
    childElem.setText(value);
    elem.addChild(childElem);

    return elem;
  }