Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange$Role


        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312?code=abc");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_GET);
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "getPerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("GetPerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here


        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_POST);
        message.setContent(InputStream.class, new ByteArrayInputStream("ssn=321&name=Nodet".getBytes()));
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "updatePerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("UpdatePerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here

        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_PUT);
        message.setContent(InputStream.class, new ByteArrayInputStream("ssn=321&name=Nodet".getBytes()));
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "addPerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("AddPerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here

        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_DELETE);
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "deletePerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("DeletePerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here

        message.setContent(Source.class, nm.getContent());
        fromNMSAttachments(message, nm);
        fromNMSHeaders(message, nm);

        if (!server) {
            MessageExchange me = message.getContent(MessageExchange.class);
            Binding binding = message.get(Binding.class);
            Operation operation = binding.getOperation(me.getOperation());
            if (operation != null) {
                if (!me.getPattern().equals(operation.getMep())) {
                    throw new Fault("Received incorrect exchange mep.  Received " + me.getPattern()
                                    + " but expected " + operation.getMep() + " for operation "
                                    + operation.getName());
                }
                message.put(Operation.class, operation);
                if (operation instanceof SoapOperation<?>) {
View Full Code Here

        this.directory = directory;
    }

    public void exchangeSent(ExchangeEvent event) {
        try {
            MessageExchange exchange = event.getExchange();
            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                OutputStream os = getOutputStream(exchange);
                NormalizedMessage in = exchange.getMessage("in");
                if (StreamSource.class.isAssignableFrom(in.getContent().getClass())) {
                    StreamSource original = (StreamSource) exchange.getMessage("in").getContent();
                    TeeInputStream tis = new TeeInputStream(original.getInputStream(), os);
                    exchange.getMessage("in").setContent(new StreamSource(tis));
                } else {
                    MessageUtil.enableContentRereadability(in);
                    SourceTransformer transformer = new SourceTransformer();
                    transformer.toResult(in.getContent(), new StreamResult(os));
                }
View Full Code Here

        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);
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);
View Full Code Here

            polling.set(true);
            polling.notify();
        }
        while (running.get()) {
            try {
                final MessageExchange exchange = channel.accept(1000L);
                if (exchange != null) {
                    final Transaction tx = (Transaction) exchange
                                    .getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
                    if (tx != null) {
                        if (transactionManager == null) {
                            throw new IllegalStateException(
                                            "Exchange is enlisted in a transaction, but no transaction manager is available");
View Full Code Here

    }
   
    public void handleMessage(Message message) {
        try {
            Operation operation = message.get(Operation.class);
            MessageExchange exchange;
            NormalizedMessage nm;
            // Create message
            if (server) {
                exchange = createExchange(message);
                if (operation != null) {
                    exchange.setOperation(operation.getName());
                }
                nm = exchange.createMessage();
                exchange.setMessage(nm, "in");
                message.setContent(MessageExchange.class, exchange);
            } else {
                exchange = message.getContent(MessageExchange.class);
                if (exchange == null) {
                    throw new IllegalStateException("Content of type " + MessageExchange.class + " not found on message");
                }
                if (message.getContent(Exception.class) == null) {
                    nm = exchange.getMessage("out");
                    if (nm == null) {
                        nm = exchange.createMessage();
                        exchange.setMessage(nm, "out");
                    }
                } else {
                    exchange.setFault(exchange.createFault());
                    nm = exchange.getFault();
                }
            }
            // Put headers
            toNMSHeaders(nm, message);
            // Put attachments
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.MessageExchange$Role

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.