Package org.xmlpull.v1.builder

Examples of org.xmlpull.v1.builder.XmlElement


        logger.finest(XMLUtil.xmlElementToString(inputElement));

        ServiceNotificationSender notifier = ServiceNotificationSender
                .invoked(inputElement);

        XmlElement nElement = inputElement.requiredElement(null, "n");
        String nString = nElement.requiredTextContent();

        int n = Integer.parseInt(nString);

        Random random = new Random();
        int msec = random.nextInt(5000);
        logger.info("Sleep for " + msec + " msec");
        try {
            Thread.sleep(msec);
        } catch (InterruptedException e) {
            logger.caught(e);
        }

        XmlNamespace namespace = XmlConstants.BUILDER.newNamespace("typens",
                "http://www.extreme.indiana.edu/math/arraygen/xsd/");
        XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace,
                "ArrayGeneratorOutput");

        XmlElement arrayElement = outputElement.addElement("output");
        for (int i = 0; i < n; i++) {
            XmlElement valueElement = arrayElement.addElement("value");
            valueElement.addChild("" + i);
        }

        if (notifier != null) {
            notifier.sendingResult(outputElement);
        }
View Full Code Here


        logger.info("Sending a message:\n"
                + XMLUtil.xmlElementToString((XmlElement) inputMessage));
        boolean success = operation.executeRequestResponseOperation(
                inputMessage, outputMessage, faultMessage);

        XmlElement result;
        if (success) {
            result = (XmlElement) outputMessage;
        } else {
            result = (XmlElement) faultMessage;
        }
View Full Code Here

        logger.finest(XMLUtil.xmlElementToString(inputElement));

        ServiceNotificationSender notifier = ServiceNotificationSender
                .invoked(inputElement);

        XmlElement xElement = inputElement.requiredElement(null, "x");
        XmlElement yElement = inputElement.requiredElement(null, "y");
        String xString = xElement.requiredTextContent();
        String yString = yElement.requiredTextContent();

        int x = Integer.parseInt(xString);
        int y = Integer.parseInt(yString);

        Random random = new Random();
        int msec = random.nextInt(10000);
        logger.info("Sleep for " + msec + " msec");
        try {
            Thread.sleep(msec);
        } catch (InterruptedException e) {
            logger.caught(e);
        }

        int z = x * y;

        String zString = "" + z;

        XmlNamespace namespace = XmlConstants.BUILDER.newNamespace(
                "multipliertypens",
                "http://www.extreme.indiana.edu/math/multiplier/xsd/");
        XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace,
                "MultiplyOutput");
        XmlElement zElement = outputElement.addElement("z");
        zElement.addChild(zString);

        if (notifier != null) {
            notifier.sendingResult(outputElement);
        }
        logger.finest(XMLUtil.xmlElementToString(outputElement));
View Full Code Here

        return (String) response.getObjectPart(DESC_AS_STRING);
    }

    private static ArrayList<String> findArrayValue(String name,
            WSIFMessageElement response) {
        XmlElement param = response.element(null, name);
        if (param != null) {
            Iterable it = param.elements(null, "value");
            if (it != null) {
                ArrayList<String> values = new ArrayList<String>();

                Iterator arrayValues = it.iterator();
                while (arrayValues.hasNext()) {
View Full Code Here

        WSIFOperation operation = port.createOperation(opName);
        WSIFMessage outputMessage = operation.createOutputMessage();
        WSIFMessage faultMessage = operation.createFaultMessage();
        String messageName = operation.createInputMessage().getName();
        XmlElement inputMsgElem = builder.newFragment(this.requestNS,
                messageName);

        for (int i = 0; i < args.length; i++) {
            createMessage((String) args[i][0], args[i][1], inputMsgElem);
        }
View Full Code Here

        }
    }

    private void createMessage(String paramName, Object value,
            XmlElement inputMsgElem) throws ComponentRegistryException {
        XmlElement paramsElem = builder.newFragment(this.requestNS, paramName);
        if (value instanceof String) {
            paramsElem.addChild(value);
        } else if (value instanceof Collection) {
            Collection list = (Collection) value;
            Iterator arrayValues = list.iterator();
            while (arrayValues.hasNext()) {
                XmlElement item = builder.newFragment("value");
                item.addChild(arrayValues.next());
                paramsElem.addChild(item);
            }
        } else if (value instanceof ArrayList) {
            Collection list = (Collection) value;
            Iterator arrayValues = list.iterator();
            while (arrayValues.hasNext()) {
                XmlElement item = builder.newFragment("value");
                item.addChild(arrayValues.next());
                paramsElem.addChild(item);
            }
        } else if (value instanceof String[]) {
            String[] list = (String[]) value;
            for (int i = 0; i < list.length; i++) {
                XmlElement item = builder.newFragment("value");
                item.addChild(list[i]);
                paramsElem.addChild(item);
            }
        } else {
            throw new ComponentRegistryException(
                    "Simple WS Client can not handle the value of type "
View Full Code Here

            WSIFOperation operation = port.createOperation("deploy");

            WSIFMessage outputMessage = operation.createOutputMessage();
            WSIFMessage faultMessage = operation.createFaultMessage();

            XmlElement inputMessageElement = xmlObjectToEl(getDeployPayload());

            WSIFMessage inputMessage = new WSIFMessageElement(inputMessageElement);


            System.out.println("Sending a message:\n"
                    + XMLUtil.xmlElementToString((XmlElement) inputMessage));
            boolean success = operation.executeRequestResponseOperation(
                    inputMessage, outputMessage, faultMessage);

            XmlElement result;
            if (success) {
                result = (XmlElement) outputMessage;
            } else {
                result = (XmlElement) faultMessage;
            }
View Full Code Here

   */
  public WsdlDefinitions setup() throws XBayaException {

    String wsdlLoc = null;
    if (this.gfacURL == null) {
      XmlElement factoryServicesElement = this.abstractDefinitions
          .element(null, "factoryServices");
      if (factoryServicesElement != null) {
        XmlElement factoryService = factoryServicesElement.element(
            null, "factoryService");
        if (factoryService != null) {
          String location = factoryService.getAttributeValue(null,
              "location");
          String portType = factoryService.getAttributeValue(null,
              "portType");
          logger.finest("location: " + location);
          logger.finest("portType: " + portType);
          wsdlLoc = WSDLUtil.appendWSDLQuary(location);
        }
View Full Code Here

        // Soap11Util.getInstance().wrapBodyContent(inputWrapper.getTarget());
        // inputWrapper.setParent(inputWrapper.getTarget().getParent()); // make
        // sure wrapper has right parent

        {
            XmlElement xmlEl = (XmlElement) inputMessage;
            XmlContainer top = xmlEl.getRoot();
            String xmlAsStr = XMLUtil.BUILDER3.serializeToString(top);
            System.out.println(xmlAsStr);
            // Object top2 = inputWrapper.getRoot();
            // System.out.println(XMLUtil.BUILDER3.serializeToString(top2));
        }

        { // required for my addder ...
            XmlDocument doc = (XmlDocument) (((XmlElement) inputMessage)
                    .getRoot());
            XmlElement env = doc.getDocumentElement();
            XmlElement header = env.element(env.getNamespace(), "Header");
            if (header == null) {
                header = env.newElement(env.getNamespace(), "Header");
                env.addElement(0, header);
            }
            header.addElement(LeadContextHeader.NS, LeadContextHeader.TYPE
                    .getLocalPart());
        }

        boolean success = operation.executeRequestResponseOperation(
                inputMessage, outputMessage, faultMessage);

        {
            XmlElement xmlEl = (XmlElement) inputMessage;
            XmlContainer top = xmlEl.getRoot();
            String xmlAsStr = XMLUtil.BUILDER3.serializeToString(top);
            System.out.println(xmlAsStr);
            // Object top2 = inputWrapper.getRoot();
            // System.out.println(XMLUtil.BUILDER3.serializeToString(top2));
        }
View Full Code Here

                if (LEADTypes.isArrayType(type)) {
                    // split string into items using " " as separator
                    Pattern pattern = Pattern.compile("[,\\s]+");
                    // String[] result = p.split("one,two, three four , five");
                    String[] result = pattern.split((String) value);
                    XmlElement arrayEl = XmlConstants.BUILDER.newFragment(name);
                    for (int i = 0; i < result.length; i++) {
                        logger.finest("split=" + result[i]);
                        arrayEl.addElement("value").addChild(result[i]);
                    }
                    this.inputMessage.setObjectPart(name, arrayEl);
                    value = null; // no need to set string value below
                }
View Full Code Here

TOP

Related Classes of org.xmlpull.v1.builder.XmlElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.