Examples of SynapseXPath


Examples of org.apache.synapse.util.xpath.SynapseXPath

            "       </makefault>" +
            "   </on-fail>" +
            "</validate>";

    private SynapseXPath createXPath(String expression) throws JaxenException {
        SynapseXPath xpath = new SynapseXPath(expression);
        xpath.addNamespace("m0", "http://services.samples/xsd");
        xpath.addNamespace("m1", "http://services.samples/xsd2");
        return xpath;
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

    public void testNamspaces() throws Exception {
        AnnotatedCommandMediator m = new AnnotatedCommandMediator();
        m.setCommand(AnnotatedCommand.class);

        SynapseXPath ax = m.afterFields.get(AnnotatedCommand.class.getDeclaredField("ReadAndUpdateField"));
        assertEquals(1, ax.getNamespaces().size());
        assertEquals("http://myns", ax.getNamespaces().values().iterator().next());
        assertEquals("myns", ax.getNamespaces().keySet().iterator().next());

        ax = m.afterFields.get(AnnotatedCommand.class.getDeclaredField("nsTest1"));
        assertEquals(2, ax.getNamespaces().size());
        assertTrue(ax.getNamespaces().keySet().contains("myns"));
        assertTrue(ax.getNamespaces().keySet().contains("ns"));
        assertTrue(ax.getNamespaces().values().contains("http://myns"));
        assertTrue(ax.getNamespaces().values().contains("http://ns"));

        ax = m.afterFields.get(AnnotatedCommand.class.getDeclaredField("nsTest2"));
        assertEquals(2, ax.getNamespaces().size());
        assertTrue(ax.getNamespaces().keySet().contains("myns"));
        assertTrue(ax.getNamespaces().keySet().contains("xns"));
        assertTrue(ax.getNamespaces().values().contains("http://myns"));
        assertTrue(ax.getNamespaces().values().contains("http://xns"));
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

    public void testSimpleHeaderXPathSetAndRemove() throws Exception {

        HeaderMediator headerMediator = new HeaderMediator();
        headerMediator.setQName(new QName(SynapseConstants.HEADER_TO));
        headerMediator.setExpression(new SynapseXPath("concat('http://','server','/path')"));

        // invoke transformation, with static enveope
        MessageContext synCtx = TestUtils.getTestContext("<empty/>");
        headerMediator.mediate(synCtx);
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        // create a new XSLT mediator
        XSLTMediator transformMediator = new XSLTMediator();

        // set xpath condition to select source
        SynapseXPath xpath = new SynapseXPath("//m0:CheckPriceRequest");
        xpath.addNamespace("m0", "http://services.samples/xsd");
        transformMediator.setSource(xpath);

        // set XSLT transformation URL
        transformMediator.setXsltKey("xslt-key");
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        // create a new switch mediator
        XSLTMediator transformMediator = new XSLTMediator();

        // set xpath condition to select source
        SynapseXPath xpath = new SynapseXPath("//m0:CheckPriceRequest");
        xpath.addNamespace("m0", "http://services.samples/xsd");
        transformMediator.setSource(xpath);

        // set XSLT transformation URL
        transformMediator.setXsltKey("xslt-key");
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        RewriteAction action2 = new RewriteAction();
        action2.setValue("/services/SimpleStockQuoteService");
        action2.setFragmentIndex(URIFragments.PATH);

        RewriteAction action3 = new RewriteAction();
        action3.setXpath(new SynapseXPath("get-property('port')"));
        action3.setFragmentIndex(URIFragments.PORT);

        RewriteRule rule2 = new RewriteRule();
        rule2.addRewriteAction(action2);
        rule2.addRewriteAction(action3);
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        RewriteAction action2 = new RewriteAction();
        action2.setValue("/services/SimpleStockQuoteService");
        action2.setFragmentIndex(URIFragments.PATH);

        RewriteAction action3 = new RewriteAction();
        action3.setXpath(new SynapseXPath("get-property('port')"));
        action3.setFragmentIndex(URIFragments.PORT);

        RewriteRule rule2 = new RewriteRule();
        rule2.addRewriteAction(action2);
        rule2.addRewriteAction(action3);
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

                commandObject);
        }

        // now set the any dynamic properties evaluating XPath's on the current message
        for (String name : messageSetterProperties.keySet()) {
            SynapseXPath xpath = messageSetterProperties.get(name);
            String value = xpath.stringValueOf(synCtx);
            PropertyHelper.setInstanceProperty(name, value, commandObject);
        }

        synLog.traceOrDebug("POJO initialized successfully, invoking the execute() method");

        // then call the execute method if the Command interface is implemented
        if (commandObject instanceof Command) {
            try {
                ((Command) commandObject).execute();
            } catch (Exception e) {
                handleException("Error invoking POJO command class : "
                    + command.getClass(), e, synCtx);
            }

        } else {

            try {
                Method exeMethod = command.getMethod("execute");
                exeMethod.invoke(commandObject);
            } catch (NoSuchMethodException e) {
                handleException("Cannot locate an execute() method on POJO class : " +
                    command.getClass(), e, synCtx);
            } catch (Exception e) {
                handleException("Error invoking the execute() method on POJO class : " +
                    command.getClass(), e, synCtx);
            }
        }

        // then set the context properties back to the messageContext from the command
        for (String name : contextGetterProperties.keySet()) {
            synCtx.setProperty(contextGetterProperties.get(name),
                getInstanceProperty(name, commandObject, synCtx));
        }

        // now set the any message properties evaluating XPath's on the current message back
        // to the message from the command
        for (String name : messageGetterProperties.keySet()) {
            SynapseXPath xpath = messageGetterProperties.get(name);

            Object resultValue = getInstanceProperty(name, commandObject, synCtx);

            try {
                List list = EIPUtils.getMatchingElements(synCtx.getEnvelope(), xpath);
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        }

        RewriteAction action = new RewriteAction();
        if (xpath != null) {
            try {
                action.setXpath(new SynapseXPath(xpath));
            } catch (JaxenException e) {
                handleException("Error while parsing the XPath expression: " + xpath, e);
            }
        } else if (value != null) {
            action.setValue(value);
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        OMAttribute attTarget = elem.getAttribute(ATT_TARGET);
        OMAttribute attProperty = elem.getAttribute(ATT_PROPERTY);
       
        if (attTarget != null) {
            try {
                mediator.setTarget(new SynapseXPath(attTarget));
            } catch (JaxenException e) {
                handleException("Invalid XPath specified for the target attribute : " +
                    attTarget.getAttributeValue());
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.