Examples of PhaseInterceptorChain


Examples of org.apache.servicemix.soap.core.PhaseInterceptorChain

    public void testDocLitOutput() throws Exception {
        ByteArrayOutputStream baos;

        Binding<?> binding = getBinding("HelloWorld-DOC.wsdl");
        PhaseInterceptorChain phaseIn = new PhaseInterceptorChain();
        phaseIn.add(binding.getInterceptors(Phase.ClientIn));
       
        Message msg = new MessageImpl();
        MessageExchange me = new MockMessageExchange();
        msg.put(Binding.class, binding);
        msg.put(Operation.class, binding.getOperations().iterator().next());
        msg.setContent(InputStream.class, getClass().getResourceAsStream("HelloWorld-DOC-Output.xml"));
        msg.setContent(MessageExchange.class, me);
        phaseIn.doIntercept(msg);

        NormalizedMessage nm = msg.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());
        baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());
       
        // check jbi message element
        Element root = DomUtil.getFirstChildElement(doc);
        assertNotNull(msg);
        assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, root.getNamespaceURI());
        assertEquals("message", root.getLocalName());
        assertEquals("HelloResponse", root.getAttribute("name"));

        // check body part
        Element part = DomUtil.getFirstChildElement(root);
        assertNotNull(part);
        assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, part.getNamespaceURI());
        assertEquals("part", part.getLocalName());

        // check body element
        Element hello = DomUtil.getFirstChildElement(part);
        assertNotNull(hello);
        assertEquals("uri:HelloWorld", hello.getNamespaceURI());
        assertEquals("HelloResponse", hello.getLocalName());
       
        // check body content
        Element e = DomUtil.getFirstChildElement(hello);
        assertNotNull(e);
        assertEquals("uri:HelloWorld", e.getNamespaceURI());
        assertEquals("text", e.getLocalName());
        assertEquals("hello", e.getTextContent());

        PhaseInterceptorChain phaseOut = new PhaseInterceptorChain();
        phaseOut.add(binding.getInterceptors(Phase.ServerOut));

        baos = new ByteArrayOutputStream();
        Message msgOut = new MessageImpl();
        msgOut.put(Binding.class, binding);
        msgOut.put(Operation.class, binding.getOperations().iterator().next());
        msgOut.setContent(OutputStream.class, baos);
        msgOut.setContent(MessageExchange.class, msg.getContent(MessageExchange.class));
        msgOut.setContent(NormalizedMessage.class, nm);
        msgOut.put(SoapVersion.class, msg.get(SoapVersion.class));
        phaseOut.doIntercept(msgOut);
        log.info(baos.toString());
       
        Document node = DomUtil.parse(new ByteArrayInputStream(baos.toByteArray()));
        Element envelope = DomUtil.getFirstChildElement(node);
        Element body = DomUtil.getFirstChildElement(envelope);
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.