Package org.apache.servicemix.soap.api

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


    public void createRequest(final MessageExchange exchange,
                              final NormalizedMessage inMsg,
                              final SmxHttpExchange httpExchange) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Message msg = binding.createMessage();
        msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
        msg.setContent(MessageExchange.class, exchange);
        msg.setContent(NormalizedMessage.class, inMsg);
        msg.setContent(OutputStream.class, baos);
        exchange.setProperty(Message.class.getName(), msg);

        InterceptorChain phaseOut = getChain(Phase.ClientOut);
        phaseOut.doIntercept(msg);
        httpExchange.setMethod(HttpMethods.POST);
View Full Code Here


        // TODO: add transport headers
        // TODO: use streaming when appropriate (?)
    }

    public void handleResponse(MessageExchange exchange, SmxHttpExchange httpExchange) throws Exception {
        Message req = (Message) exchange.getProperty(Message.class.getName());
        exchange.setProperty(Message.class.getName(), null);
        Message msg = binding.createMessage(req);
        msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
        msg.setContent(MessageExchange.class, exchange);
        msg.setContent(InputStream.class, new ByteArrayInputStream(httpExchange.getResponseData()));
        msg.put(StaxInInterceptor.ENCODING, httpExchange.getResponseEncoding());
        InterceptorChain phaseOut = getChain(Phase.ClientIn);
        phaseOut.doIntercept(msg);
        // TODO: Retrieve headers ?
    }
View Full Code Here

        this.policies = policies;
    }

    public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
        String method = request.getMethod();
        Message msg = binding.createMessage();
        msg.put(ComponentContext.class, context);
        msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
        msg.put(Message.CONTENT_TYPE, request.getContentType());
        Map<String, String> headers = msg.getTransportHeaders();
        for (Enumeration<?> e = request.getHeaderNames(); e.hasMoreElements();) {
            String name = (String) e.nextElement();
            String value = request.getHeader(name);
            headers.put(name, value);
        }
        headers.put(HttpConstants.REQUEST_URI, request.getRequestURL().toString());
        headers.put(HttpConstants.CONTENT_TYPE, request.getContentType());
        headers.put(HttpConstants.REQUEST_METHOD, method);
        if (HttpConstants.METHOD_POST.equals(method) || HttpConstants.METHOD_PUT.equals(method)) {
            msg.setContent(InputStream.class, request.getInputStream());
        }
        request.setAttribute(Message.class.getName(), msg);
        InterceptorChain phase = getChain(Phase.ServerIn);
        phase.doIntercept(msg);
        return msg.getContent(MessageExchange.class);
    }
View Full Code Here

public class StaxInInterceptorTest extends TestCase {

    private StaxInInterceptor interceptor = new StaxInInterceptor();
   
    public void testNullInput() {
        Message msg = new MessageImpl();
        interceptor.handleMessage(msg);
        assertNull(msg.getContent(XMLStreamReader.class));
    }
View Full Code Here

        interceptor.handleMessage(msg);
        assertNull(msg.getContent(XMLStreamReader.class));
    }
   
    public void testValidInput() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<hello/>".getBytes());
        msg.setContent(InputStream.class, is);
        interceptor.handleMessage(msg);
        XMLStreamReader reader = msg.getContent(XMLStreamReader.class);
        assertNotNull(reader);
        assertEquals(new QName("hello"), reader.getName());
    }
View Full Code Here

public class DomInInterceptorTest extends TestCase {

    private DomInInterceptor interceptor = new DomInInterceptor();
   
    public void testNullInput() {
        Message msg = new MessageImpl();
        interceptor.handleMessage(msg);
        assertNull(msg.getContent(Document.class));
    }
View Full Code Here

        interceptor.handleMessage(msg);
        assertNull(msg.getContent(Document.class));
    }
   
    public void testValidInput() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<hello/>".getBytes());
        msg.setContent(InputStream.class, is);
        interceptor.handleMessage(msg);
        Document doc = msg.getContent(Document.class);
        assertNotNull(doc);
        assertEquals("hello", doc.getDocumentElement().getLocalName());
    }
View Full Code Here

        wsdlMessage.setName(new QName("urn:test", "message"));
        wsdlOperation.setInput(wsdlMessage);

        String input = "<hello />";
       
        Message message = new MessageImpl();
        message.put(Operation.class, wsdlOperation);
        XMLStreamReader reader = StaxUtil.createReader(new ByteArrayInputStream(input.getBytes()));
        reader.nextTag();
        message.setContent(XMLStreamReader.class, reader);
       
        JbiInWsdl1Interceptor interceptor = new JbiInWsdl1Interceptor(true);
        interceptor.handleMessage(message);
        Source source = message.getContent(Source.class);
        assertNotNull(source);
        Document doc = DomUtil.parse(source);
        Element root = doc.getDocumentElement();
        assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, root.getNamespaceURI());
        assertEquals(JbiConstants.WSDL11_WRAPPER_MESSAGE_LOCALNAME, root.getLocalName());
View Full Code Here

    public AbstractBinding() {
        operations = new HashMap<QName, T>();
    }
   
    public Message createMessage() {
        Message in = new MessageImpl();
        in.put(Binding.class, this);
        return in;
    }
View Full Code Here

        in.put(Binding.class, this);
        return in;
    }
   
    public Message createMessage(Message request) {
        Message out = new MessageImpl();
        out.put(Binding.class, this);
        out.put(Operation.class, request.get(Operation.class));
        return out;
    }
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.