Package org.xmlpull.v1.builder

Examples of org.xmlpull.v1.builder.XmlElement


         * @param type
         * @param message
         */
        public void deliverMessage(String topic, NotificationType type, XmlObject message) {

            XmlElement event = XBeansUtil.xmlObjectToXmlElement(message);
            this.eventData.addEvent(XMLUtil.xmlElement3ToXmlElement5(event));
        }
View Full Code Here


    public void setInput(String name, Object value) throws WorkflowException {
        try {
            if (value instanceof XmlElement) {
                // If the value is a complex type, change the name of the
                // element to the correct one.
                XmlElement valueElement = (XmlElement) value;
                valueElement.setName(name);
            } else if (value instanceof String) {
                    if(XMLUtil.isXML((String)value)){
                     XmlElement valueElement = XMLUtil.stringToXmlElement3((String) value);
                     valueElement.setName(name);
                        value = valueElement;
                }
                // Simple case.
            } else {
                // convert int, doule to string.
View Full Code Here

        try {
            // This code doesn't work when the output is a complex type.
            // Object output = this.outputMessage.getObjectPart(name);
            // return output;

            XmlElement outputElement = (XmlElement) this.outputMessage;
            XmlElement valueElement = outputElement.element(null, name);
            Iterator childIt = valueElement.children();
            int numberOfChildren = 0;
            while (childIt.hasNext()) {
                childIt.next();
                numberOfChildren++;
            }
            if (numberOfChildren == 1) {
                Object child = valueElement.children().next();
                if (child instanceof String) {
                    // Value is a simple type. Return the string.
                    String value = (String) child;
                    return value;
                }
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 " + value);
        }
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

     */
    public XmlElement add(XmlElement inputElement) {
        logger.info(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);

        int z = x + y;

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

        String zString = "" + z;

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

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

        leadContext.setWorkflowId(URI.create("http://host/2005/11/09/workflowinstace"));
        leadContext.setNodeId("decoder1");
        leadContext.setTimeStep("5");
        leadContext.setServiceInstanceId(URI.create("decoder-instance-10"));

        XmlElement element3 = XMLUtil.xmlElement5ToXmlElement3(definitions.xml());
        xsul.wsdl.WsdlDefinitions definitions3 = new xsul.wsdl.WsdlDefinitions(element3);

        WSIFClient wclient = WSIFRuntime.getDefault().newClientFor(definitions3, "TestCMD_Example1SoapPort");
        StickySoapHeaderHandler handler = new StickySoapHeaderHandler("use-lead-header", leadContext);

        wclient.addHandler(handler);
        wclient.useAsyncMessaging(correlator);
        wclient.setAsyncResponseTimeoutInMs(33000L);

        WSIFPort port = wclient.getPort();
        WSIFOperation operation = port.createOperation("Run");
        WSIFMessage inputMessage = operation.createInputMessage();
        WSIFMessage outputMessage = operation.createOutputMessage();
        WSIFMessage faultMessage = operation.createFaultMessage();

        // inputMessage.setObjectPart("InputParam1", "Hello");
        inputMessage.setObjectPart("InputParam1", "100");

        logger.info("inputMessage: " + XsulUtil.safeXmlToString((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 void setInput(String name, Object value) throws WorkflowException {
        try {
            if (value instanceof XmlElement) {
                // If the value is a complex type, change the name of the
                // element to the correct one.
                XmlElement valueElement = (XmlElement) value;
                valueElement.setName(name);
            } else if (value instanceof String) {
                    if(XMLUtil.isXML((String)value)){
                     XmlElement valueElement = XMLUtil.stringToXmlElement3((String) value);
                     valueElement.setName(name);
                        value = valueElement;
                }
                // Simple case.
            } else {
                // convert int, doule to string.
View Full Code Here

        try {
            // This code doesn't work when the output is a complex type.
            // Object output = this.outputMessage.getObjectPart(name);
            // return output;

            XmlElement outputElement = (XmlElement) this.outputMessage;
            XmlElement valueElement = outputElement.element(null, name);
            Iterator childIt = valueElement.children();
            int numberOfChildren = 0;
            while (childIt.hasNext()) {
                childIt.next();
                numberOfChildren++;
            }
            if (numberOfChildren == 1) {
                Object child = valueElement.children().next();
                if (child instanceof String) {
                    // Value is a simple type. Return the string.
                    String value = (String) child;
                    return value;
                }
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.