Package org.servicemix.jbi.jaxp

Examples of org.servicemix.jbi.jaxp.StringSource


    private String property;
   
    protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
            throws MessagingException {
        out.setContent(new StringSource("<hello>" + in.getProperty(property) + "</hello>"));
        return true;
    }
View Full Code Here


        ServiceMixClient client=(ServiceMixClient) ctx.getBean("client");
        Thread.sleep(5000);
        InOut exchange=client.createInOutExchange();
        exchange.setService(new QName("http://www.habuma.com/foo","pingService"));
        NormalizedMessage in=exchange.getInMessage();
        in.setContent(new StringSource("<ping>Pinging you</ping>"));
        System.out.println("SENDING; exchange.status="+exchange.getStatus());
        client.sendSync(exchange);
        assertNotNull(exchange.getOutMessage());
        System.out.println("GOT RESPONSE; exchange.out="+new SourceTransformer().toString(exchange.getOutMessage().getContent()));
        client.done(exchange);
View Full Code Here

public class PingService extends ComponentSupport implements MessageExchangeListener{
    public void onMessageExchange(MessageExchange exchange) throws MessagingException{
        if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            System.out.println("GOT A MESSAGE; exchange.status="+exchange.getStatus());
            NormalizedMessage out=exchange.createMessage();
            out.setContent(new StringSource("<response>Ping back at ya!</response>"));
            System.out.println("SENDING RESPONSE; exchange.status="+exchange.getStatus());
            answer(exchange,out);
            System.out.println("RESPONSE SENT; exchange.status="+exchange.getStatus());
        } else {
            System.out.println("GOT A MESSAGE; exchange.status="+exchange.getStatus());
View Full Code Here

            }

            exchange.setInMessage(message);
            // lets set the XML as a byte[], String or DOM etc
            String xml = "<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'><s12:Body> <foo>Hello!</foo> </s12:Body></s12:Envelope>";
            message.setContent(new StringSource(xml));
            if (sync) {
              boolean result = context.getDeliveryChannel().sendSync(exchange, 1000);
                if (!result) {
                    throw new MessagingException("Message delivery using sendSync has timed out");
                }
View Full Code Here

                NormalizedMessage message = exchange.createMessage();
                exchange.setEndpoint(endpoint);
                exchange.setInMessage(message);
                // lets set the XML as a byte[], String or DOM etc
                String xml = "<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'><s12:Body> <foo>Hello!</foo> </s12:Body></s12:Envelope>";
                message.setContent(new StringSource(xml));
                System.out.println("sending message: " + i);
                DeliveryChannel deliveryChannel = context.getDeliveryChannel();
                System.out.println("sync send on deliverychannel: " + deliveryChannel);
                if (sync) {
                  deliveryChannel.sendSync(exchange);
View Full Code Here

        }
        public DocumentFragment getAsReference(QName operationName) {
            try {
                SourceTransformer st = new SourceTransformer();
                String xml = new XStream(new DomDriver()).toXML(this);
                Document doc = (Document) st.toDOMNode(new StringSource(xml));
                DocumentFragment df = doc.createDocumentFragment();
                df.appendChild(doc.getDocumentElement());
                return df;
            } catch (Exception e) {
                throw new RuntimeException(e);
View Full Code Here

  public void testInOnly() throws Exception {
    // Send message exchange
    MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
    InOnly mec = mef.createInOnlyExchange();
    NormalizedMessage m = mec.createMessage();
    m.setContent(new StringSource(PAYLOAD));
    mec.setInMessage(m);
        assertEquals(Role.CONSUMER, mec.getRole());
        try {
            mec.setMessage(null, "in");
            fail("Message is null");
View Full Code Here

    }).start();
    // Send message exchange
    MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
    InOnly mec = mef.createInOnlyExchange();
    NormalizedMessage m = mec.createMessage();
    m.setContent(new StringSource(PAYLOAD));
    mec.setInMessage(m);
    boolean result = consumer.getChannel().sendSync(mec, 10000L);
        assertTrue(result);
    assertEquals(ExchangeStatus.DONE, mec.getStatus());
    // Nothing left
View Full Code Here

    public void testInOnlySyncWithTimeoutBeforeAccept() throws Exception {
        // Send message exchange
        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
        InOnly mec = mef.createInOnlyExchange();
        NormalizedMessage m = mec.createMessage();
        m.setContent(new StringSource(PAYLOAD));
        mec.setInMessage(m);
        boolean result = consumer.getChannel().sendSync(mec, 100L);
        assertFalse(result);
        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
        // Nothing left
View Full Code Here

        t.start();
        // Send message exchange
        MessageExchangeFactory mef = consumer.getChannel().createExchangeFactoryForService(new QName("provider"));
        InOnly mec = mef.createInOnlyExchange();
        NormalizedMessage m = mec.createMessage();
        m.setContent(new StringSource(PAYLOAD));
        mec.setInMessage(m);
        boolean result = consumer.getChannel().sendSync(mec, 50L);
       
        assertFalse(result);
        assertEquals(ExchangeStatus.ERROR, mec.getStatus());
View Full Code Here

TOP

Related Classes of org.servicemix.jbi.jaxp.StringSource

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.