Package org.switchyard

Examples of org.switchyard.Message


     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    @Override
    public IndexedRecordBindingData decompose(Exchange exchange, IndexedRecordBindingData target) throws Exception {
        Message sourceMessage = exchange.getMessage();

        getContextMapper().mapTo(exchange.getContext(), target);
        final List<?> content = sourceMessage.getContent(List.class);
        target.getRecord().addAll(content);
        return target;
    }
View Full Code Here


                    camelFault = bindingData.getMessage().getBody();
                }
            }
           
            if (camelFault != null && declaredFault != null && declaredFault.isAssignableFrom(camelFault.getClass())) {
                Message msg = null;
                try {
                    msg = _messageComposer.compose(bindingData, switchyardExchange);
                } catch (Exception e) {
                    throw new HandlerException(e);
                }
View Full Code Here

            }
        }
    }

    private void sendResponseToSwitchyard(final Exchange switchyardExchange, CamelBindingData bindingData) throws HandlerException {
        Message msg = null;
        try {
            msg = _messageComposer.compose(bindingData, switchyardExchange);
        } catch (Exception e) {
            throw new HandlerException(e);
        }
View Full Code Here

            if (operationName != null) {
                exchangeIn = serviceReference.createExchange(operationName, handler);
            } else {
                exchangeIn = serviceReference.createExchange(handler);
            }
            Message messageIn = exchangeIn.createMessage();
            Context contextIn = exchangeIn.getContext(messageIn);
            for (Map.Entry<String,Object> entry : request.getContext().entrySet()) {
                contextIn.setProperty(entry.getKey(), entry.getValue());
            }
            Object contentIn = request.getContent();
            if (contentIn != null) {
                messageIn.setContent(contentIn);
            }
            exchangeIn.send(messageIn);
            if (ExchangePattern.IN_OUT.equals(exchangeIn.getContract().getConsumerOperation().getExchangePattern())) {
                Exchange exchangeOut = handler.waitForOut();
                Message messageOut = exchangeOut.getMessage();
                contentOut = messageOut.getContent();
                for (Property property : exchangeOut.getContext(messageOut).getProperties()) {
                    contextOut.put(property.getName(), property.getValue());
                }
            }
            fault = handler.getFault();
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public Message compose(CamelBindingData source, Exchange exchange) throws Exception {
        Message message = exchange.createMessage();

        // map context properties
        getContextMapper().mapFrom(source, exchange.getContext(message));

        org.apache.camel.Message sourceMessage = source.getMessage();

        // map content
        QName msgType = getMessageType(exchange);
        Object content;
        if (msgType == null) {
            content = sourceMessage.getBody();
        } else if (QNameUtil.isJavaMessageType(msgType)) {
            content = sourceMessage.getBody(QNameUtil.toJavaMessageType(msgType));
        } else {
            content = sourceMessage.getBody();
            if (!(content instanceof String) && !(content instanceof Node)
                    && !(content instanceof InputSource) && !(content instanceof Source)) {
                // named binary content - content is not String nor XML, but has type name other than "java:*"
                content = sourceMessage.getBody(InputStream.class);
            }
        }
        message.setContent(content);

        Set<String> attachements = sourceMessage.getAttachmentNames();
        if (!attachements.isEmpty()) {
            for (Entry<String, DataHandler> entry : sourceMessage.getAttachments().entrySet()) {
                message.addAttachment(entry.getKey(), entry.getValue().getDataSource());
            }
        }

        return message;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
        Message sourceMessage = exchange.getMessage();
        getContextMapper().mapTo(exchange.getContext(), target);

        org.apache.camel.Message targetMessage = target.getMessage();

        if (!sourceMessage.getAttachmentMap().isEmpty()) {
            for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) {
                targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue()));
            }
        }

        ServiceOperation operation = exchange.getContract().getProviderOperation();
        target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName());
        target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType());
        target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName());

        targetMessage.setBody(sourceMessage.getContent());
        return target;
    }
View Full Code Here

    @Override
    public void handleMessage(Exchange exchange) throws HandlerException {
        if (exchange.getContract().getProviderOperation().getExchangePattern().equals(ExchangePattern.IN_OUT)) {
            String response = null;
            Message message = exchange.createMessage();
            Node request = exchange.getMessage().getContent(Node.class);
            Element orderId = XMLHelper.getFirstChildElementByName(request, "orderId");

            if (orderId != null && orderId.getFirstChild().getNodeValue().equals("PO-121212-XYZ")) {
                response = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
View Full Code Here

    }

    @Test
    public void unknownHost() throws Exception {
        try {
            Message responseMsg = _proxyConsumerService1.operation(METHOD_NAME).sendInOut(INPUT);
        } catch (Exception e) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(baos));
            Assert.assertTrue(baos.toString().contains("org.apache.http.NoHttpResponseException: unreachablehost")
                    || baos.toString().contains("UnknownHostException: unreachablehost"));
View Full Code Here

    @Test
    public void authenticationMissing() throws Exception {
        MockHandler handler = new MockHandler();
        Exchange ex = _proxyConsumerService2.operation(METHOD_NAME).createExchange(handler);
        Message requestMsg = ex.createMessage().setContent(INPUT);
        ex.send(requestMsg);
        handler.waitForFaultMessage();
        String response = ex.getMessage().getContent(String.class);
        Assert.assertTrue(response.contains("407 Proxy Authentication Required"));
    }
View Full Code Here

        Assert.assertTrue(response.contains("407 Proxy Authentication Required"));
    }

    @Test
    public void allIsWell() throws Exception {
        Message responseMsg = _proxyConsumerService3.operation(METHOD_NAME).sendInOut(INPUT);
        Assert.assertEquals(INPUT, responseMsg.getContent(String.class));
    }
View Full Code Here

TOP

Related Classes of org.switchyard.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.