Package org.apache.servicemix.soap.api

Examples of org.apache.servicemix.soap.api.Message


        interceptor = new WsdlOperationInInterceptor();
    }
   
    public void test() throws Exception {
        String str = "<hello />";
        Message message = createDefaultMessage(str);
        interceptor.handleMessage(message);
       
        assertNotNull(message.get(Operation.class));
    }
View Full Code Here


       
        assertNotNull(message.get(Operation.class));
    }

    private Message createDefaultMessage(String str) throws Exception {
        Message message = new MessageImpl();
        message.put(Binding.class, binding);
        XMLStreamReader reader = StaxUtil.createReader(new ByteArrayInputStream(str.getBytes()));
        message.setContent(XMLStreamReader.class, reader);
        reader.nextTag();
        return message;
    }
View Full Code Here

    public void test() {
        PhaseInterceptorChain chain = new PhaseInterceptorChain();
        MustUnderstandInterceptor interceptor = new MustUnderstandInterceptor();
        SoapVersion soapVersion = Soap11.getInstance();
       
        Message message = new MessageImpl();
        message.put(InterceptorChain.class, chain);
        message.put(SoapVersion.class, soapVersion);
        message.getSoapHeaders().put(HEADER_QNAME, createHeader(HEADER_QNAME, soapVersion));
       
        try {
            interceptor.handleMessage(message);
            fail("A SoapFault should have been thrown");
        } catch (SoapFault fault) {
View Full Code Here

        Binding<?> binding = getBinding("HelloWorld-RPC.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-RPC-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(root);
        assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, root.getNamespaceURI());
        assertEquals("message", root.getLocalName());
        assertEquals("HelloResponse", root.getAttribute("name"));

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

        // check part content
        assertTrue( "Unexpected part element", DomUtil.getFirstChildElement(part) == null);
        assertEquals("hello", part.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);
View Full Code Here

public class JbiInInterceptorTest extends TestCase {

    public void test() throws Exception {
        Interceptor interceptor = new JbiInInterceptor(true);
        Message message = new MessageImpl();
        message.put(JbiInInterceptor.OPERATION_MEP, JbiConstants.IN_ONLY);
        message.put(MessageExchangeFactory.class, new MockExchangeFactory());
        message.setContent(Source.class, new StreamSource(new StringReader("<hello/>")));
        message.getTransportHeaders().put("Content-Type", "text/xml");
       
        interceptor.handleMessage(message);
       
        MessageExchange me = message.getContent(MessageExchange.class);
        assertNotNull(me);
        assertTrue(me instanceof InOnly);
        NormalizedMessage nm = me.getMessage("in");
        assertNotNull(nm);
        assertNotNull(nm.getContent());
View Full Code Here

    private SoapInInterceptor interceptor = new SoapInInterceptor();
   
    public void testNullInput() {
        try {
            Message msg = new MessageImpl();
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown an NPE");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

        } catch (NullPointerException e) {
        }
    }
   
    public void testBadNamespace() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<hello/>".getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        try {
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown a SoapFault");
        } catch (SoapFault e) {
View Full Code Here

            log.info(e.getMessage(), e);
        }
    }
   
    public void testBadLocalName() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<test xmlns='http://www.w3.org/2003/05/soap-envelope'/>".getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        try {
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown a SoapFault");
        } catch (SoapFault e) {
View Full Code Here

            log.info(e.getMessage(), e);
        }
    }
   
    public void testEmptyEnvelopeName() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'/>".getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        try {
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown a SoapFault");
        } catch (SoapFault e) {
View Full Code Here

                     "  </s:Header>" +
                     "  <s:Body>" +
                     "    <hello>world</hello>" +
                     "  </s:Body>" +
                     "</s:Envelope>";
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream(str.getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        interceptor.handleMessage(msg);
       
        assertNotNull(msg.get(SoapVersion.class));
        assertEquals("s", msg.get(SoapVersion.class).getPrefix());
        assertNotNull(msg.getSoapHeaders().get(new QName("header1")));
        assertEquals(2, msg.getSoapHeaders().get(new QName("header1")).getChildNodes().getLength());
        assertNotNull(msg.getSoapHeaders().get(new QName("urn:y", "header2")));
        assertEquals(1, msg.getSoapHeaders().get(new QName("urn:y", "header2")).getChildNodes().getLength());
        assertNotNull(msg.getContent(XMLStreamReader.class));
        assertEquals(XMLStreamConstants.START_ELEMENT, msg.getContent(XMLStreamReader.class).getEventType());
        assertEquals(new QName("hello"), msg.getContent(XMLStreamReader.class).getName());
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.soap.api.Message

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.